Salesforce AppExchange Installation
This guide walks Salesforce administrators through setting up the Barid AppExchange app for sending Letters and Invoices.
Prerequisites
- Salesforce org (Sandbox or Production)
- System Administrator profile or equivalent permissions
- Barid API credentials (API Key and Secret)
Step 1: Install the Package
- Navigate to the Barid listing on AppExchange
- Click Get It Now
- Select your org and follow the installation wizard
- Choose "Install for Admins Only" initially (you can grant access later)
Step 2: Configure API Credentials (External Credentials)
API credentials are stored securely using Salesforce External Credentials. This ensures your API Key and Secret are hidden in the UI and never exposed in metadata.
The package includes two External Credentials - one for production and one for test. Configure the one matching your environment:
-
Go to Setup → Named Credentials
-
Click the External Credentials tab
-
Find Barid API (Production) or Barid API (Test) and click on it
-
Under Principals, find Barid_User and click on it (not Edit)
-
Click Edit on the principal detail page
-
Under Authentication Parameters, click Add and create two parameters:
- Name:
X_Api_Client_Id, Value: Your Barid API Key - Name:
X_Api_Client_Secret, Value: Your Barid API Secret (will be masked after saving)
ImportantUse underscores (
_) in parameter names, NOT hyphens. Hyphens cause formula errors. - Name:
-
Click Save
The Custom Headers on the Named Credential are pre-configured by the package to automatically inject these credentials as HTTP headers. No additional Named Credential configuration is required.
Configure Barid Settings
- Go to Setup → Custom Metadata Types
- Click Manage Records next to Barid Settings
- Click New or edit the existing record
- Configure the following fields:
| Field | Description | Default / Example |
|---|---|---|
| API Environment | Select Test, QA, or Production | Test (default) |
| Timeout (s) | API timeout in seconds | 120 |
| Auto Send Invoices | Enable automatic invoice sending | Unchecked |
| Cron Expression | Schedule for batch job (leave blank to disable) | 0 0 * * * ? (hourly) |
| Invoice Trigger Status | Invoice status that triggers automatic sending | Posted |
| Emirates ID Field | (Optional) API name of custom field containing Emirates ID | Emirates_ID__c |
| Invoice Reference Field | (Optional) API name of Invoice field to use as reference | Custom_Reference__c |
| Order Reference Field | (Optional) API name of Order field to use as reference | PO_Number__c |
The API Environment setting determines which External Credential is used. Select "Production" when you're ready to go live.
Emirates ID Field Configuration (Optional)
If your org has a custom field on Account to store Emirates ID, you can configure Barid to use it for more accurate customer lookup:
- Enter the API name of the field (e.g.,
Emirates_ID__c) - The field must be on the Account object
- Leave blank to use phone/email lookup only
Emirates ID lookup is preferred over phone/email as it provides more accurate customer matching in the Barid system.
Invoice/Order Reference Field Configuration (Optional)
By default, the Invoice Sender component uses:
- Invoice:
DocumentNumberfield - Order:
OrderNumberfield
To use a different field as the reference number sent to Barid:
- Enter the API name of the field (e.g.,
Custom_Reference__corPO_Number__c) - The field must exist on the respective object (Invoice or Order)
- Leave blank to use the default field
Step 3: Configure Remote Site Settings
- Go to Setup → Remote Site Settings
- Click New Remote Site
- Add the Barid API endpoint:
| Field | Value |
|---|---|
| Remote Site Name | BaridAPI |
| Remote Site URL | https://sender.api.barid.ae or https://test.sender.api.barid.ae |
| Active | Checked |
Step 4: Grant User Access
The package includes a Barid User permission set that grants access to Barid features.
Assign Permission Set to Users
- Go to Setup → Permission Sets
- Click Barid User
- Click Manage Assignments → Add Assignment
- Select the users who need to send documents via Barid
- Click Assign
The permission set grants:
- Access to all Barid Apex classes
- Read/Create/Edit access to
Document__c(for tracking sent documents) - External Credential Principal Access for both Test and Production APIs
Users will also need access to relevant standard objects (Account, Contact, Order, etc.) through their profile or other permission sets.
Step 5: Add Components to Page Layouts
Add Letter Sender to Record Pages
- Go to Setup → Object Manager
- Select the object (e.g., Account, Contact, ContentDocument)
- Click Lightning Record Pages
- Edit the page or create a new one
- Drag Send Letter via Barid component onto the page
- Click Save → Activate
Add Quick Action to Page Layout
The package includes a Send via Barid Quick Action for Account. After deployment, add it to the page layout:
- Go to Setup → Object Manager → Account
- Click Page Layouts
- Edit the layout
- In the palette, find Send via Barid under "Mobile & Lightning Actions"
- Drag the action to Salesforce Mobile and Lightning Experience Actions
- Click Save
When users click this action on an Account, they can select from any PDF files attached to that Account and send them via Barid.
Quick Actions for Other Objects
The package includes Quick Actions for Account, Contact, Contract, and Order. To add them to page layouts:
- Go to Setup → Object Manager → Select the object (Account, Contact, Contract, or Order)
- Click Page Layouts
- Edit the layout
- Find Send via Barid or Send To Barid under "Mobile & Lightning Actions"
- Drag the action to Salesforce Mobile and Lightning Experience Actions
- Click Save
Create Quick Actions for Additional Objects (Opportunity, Case, etc.)
To add Quick Actions on objects not included in the package:
- Go to Setup → Object Manager → Select the object → Buttons, Links, and Actions
- Click New Action
- Configure:
- Action Type: Lightning Web Component
- Lightning Web Component: c:baridLetterSender
- Label: Send via Barid
- Name:
Send_via_Barid
- Click Save
- Add to page layout as described above
Add Invoice Sender to Order Records
The base Barid package includes a Send To Barid Quick Action for Order objects:
- Go to Setup → Object Manager → Order
- Click Page Layouts
- Edit the layout
- In the palette, find Send To Barid under "Mobile & Lightning Actions"
- Drag the action to Salesforce Mobile and Lightning Experience Actions
- Click Save
Alternatively, add the component directly to the Lightning Record Page:
- Go to Setup → Object Manager → Order
- Click Lightning Record Pages
- Edit the page
- Drag Barid Invoice Sender component onto the page
- Click Save → Activate
Invoice Quick Action (Salesforce Billing)
For orgs with Salesforce Billing, a separate Barid for Billing extension package is available on AppExchange. This extension adds a pre-configured Send Invoice to Barid Quick Action on the Invoice object.
- Install the Barid for Billing package from AppExchange (requires the base Barid package)
- Go to Setup → Object Manager → Invoice
- Click Page Layouts
- Edit the layout
- Find Send Invoice to Barid under "Mobile & Lightning Actions"
- Drag the action to Salesforce Mobile and Lightning Experience Actions
- Click Save
The base Barid package already contains all invoice functionality. The extension simply provides a ready-to-use Quick Action on the Invoice object.
Step 6: Configure Automatic Invoice Sending (Optional)
If you want invoices to be automatically sent to Barid when they reach a specific status (e.g., "Posted"), follow these steps:
6a. Enable Auto-Send in Settings
- Go to Setup → Custom Metadata Types
- Click Manage Records next to Barid Settings
- Edit your settings record
- Check Auto Send Invoices
- Set Cron Expression for the schedule frequency (see examples below)
- Set Invoice Trigger Status to the status that should trigger sending (default:
Posted) - Click Save
Cron Expression Examples:
| Schedule | Cron Expression |
|---|---|
| Every hour | 0 0 * * * ? |
| Every 30 minutes | 0 0,30 * * * ? |
| Daily at midnight | 0 0 0 * * ? |
| Daily at 8 AM | 0 0 8 * * ? |
6b. Activate the Schedule
After configuring settings, run this Apex command once to activate the schedule:
BaridInvoiceScheduler.syncSchedule();
This reads your Barid Settings and creates (or removes) the scheduled job accordingly. Run this command again whenever you change the Auto Send Invoices or Cron Expression settings.
6c. Verify the Schedule
To check if the job is scheduled:
System.debug(BaridInvoiceScheduler.isScheduled());
To see schedule details:
System.debug(BaridInvoiceScheduler.getScheduleDetails());
To manually remove the scheduled job:
BaridInvoiceScheduler.unschedule();
How It Works
- The scheduler runs at your configured interval
- It queries Invoices with the trigger status (e.g., "Posted")
- Invoices that haven't been processed are sent to Barid
- Each invoice creates a
Document__crecord to track status - Already-processed invoices are skipped (prevents duplicates)
This feature requires the Salesforce Billing Invoice object. If your org doesn't have Salesforce Billing, the scheduler will skip processing automatically. The app can still be installed and used for manual letter sending.
Step 7: Verify Installation
Test API Connection
- Open an Account record
- Look for the Send Letter via Barid component
- The component should load without errors
Send a Test Letter
- Upload a PDF file to an Account record
- Click Send via Barid (Quick Action) or use the component
- Enter a title and verify the recipient is auto-detected
- Click Send Letter
- Check the Barid Documents related list for status
Custom Object: Barid Document
The app creates Document__c records to track sent documents:
| Field | Description |
|---|---|
| Name | Auto-generated ID (BD-0001, etc.) |
| Status | Pending, Sent, Delivered, or Failed |
| Document Type | Letter or Invoice |
| File Name | Original filename |
| Sent Date | When successfully sent |
| Document Id | Barid system reference ID |
| Error Message | Details if sending failed |
Add Related List to Page Layouts
- Go to Object Manager → Account (or other objects)
- Click Page Layouts
- Edit the layout
- Drag Barid Documents related list onto the page
- Click Save
Platform Cache (Optional)
For better performance, enable Platform Cache:
- Go to Setup → Platform Cache
- Create a partition named
BaridCache - Allocate at least 1 MB to the session cache
The app uses Platform Cache to store API sessions (~30 minute TTL), reducing authentication calls.
Troubleshooting
"Recipient not found in Barid"
The Account holder must be registered in the Barid system. The app uses standard Salesforce fields to look up customers:
For Person Accounts:
PersonEmailfieldPhoneorPersonMobilePhonefield
For Business Accounts:
Phonefield on the Account- Email from the primary Contact
Ensure at least one of these fields has a value that matches the customer's Barid registration.
"No PDF files attached"
The component only shows PDF files. Ensure:
- Files are uploaded as Salesforce Files (not Attachments)
- File extension is
.pdf
API Connection Errors
- Verify Remote Site Settings include the Barid API URL
- Check that External Credential has
X_Api_Client_IdandX_Api_Client_Secretparameters configured (Setup → Named Credentials → External Credentials tab → click on the principal) - Ensure the user has the Barid User permission set assigned (this grants access to the External Credential)
- Test the API credentials in Barid's dashboard
Permission Errors / Button Not Visible
If the "Send To Barid" button doesn't appear or users get permission errors:
- Assign the Barid User permission set to the user (Setup → Permission Sets → Barid User → Manage Assignments)
- Ensure the Quick Action has been added to the page layout (see Step 5)
- Verify users have access to Salesforce Files (ContentDocument, ContentVersion) through their profile
Support
For issues or questions:
- Check the Barid API Documentation
- Contact Barid support
- Review error messages in
Document__crecords
Developer Notes (Scratch Orgs)
When developing with scratch orgs, the project uses the Barid namespace defined in sfdx-project.json. This means:
- External Credentials are deployed with the
Barid__namespace prefix - Named Credential formulas reference
{!$Credential.API_Test.X_Api_Client_Id}(without namespace prefix - Salesforce resolves this automatically) - Permission Set includes External Credential Principal Access automatically
No manual configuration is required for scratch orgs created from this project.