Salesforce connector is a component available in Mule for consuming the operations and functionalities from a Salesforce System. While creating an application we can use the functionality of Salesforce connector to do Salesforce
events such as adding, changing, deleting etc.
Salesforce connector can enable the connectivity to the Salesforce APIs. Such as SOAP API, REST API, Bulk API and Streaming API.REST APIs most of the time use APEX classes.
Create a User Account with few fields and trigger a rule on creating User.
- Create a flow and add Create Salesforce operation
- Specify the object as Account and pass the payload
- This operation will make a API call internally and for calling an API requires few things:
- Required Parameters
- Optional Parameters
Take a sample configuration for creating an Account in Salesforce is given below:
Once we complete the execution of the flow you will receive a success message, however it will not trigger the requested rule as the required headers are not passed.
In Salesforce we have different types of Headers available and we can pass those values through the header part in Salesforce connector.
1.Assignment Rule Header
The Assignment Rule header is a request header applied when creating or updating Accounts, Cases, or Leads. If enabled, the active assignment rules are used. If disabled, the active assignment rules are not applied. If a valid AssignmentRule ID is provided, the AssignmentRule is applied. If the header is not provided with a request, REST API defaults to using the active assignment rules.
2.Call Options Header
Specifies client-specific options when accessing REST API resources. For example, you can write client code that ignores namespace prefixes by specifying the prefix in the call options header.
3.Limit Info Header
This response header is returned in each request to REST API. You can use the information to monitor API limits.
4.Package Version Header
Specifies the version of each package referenced by a client. A package version is a number that identifies the set of components and behavior contained in a package. This header can also be used to specify a package version when making calls to an Apex REST web service.
5.Query Options Header
Specifies options used in a query, such as the query results batch size. Use this request header with the Query resource.
How to pass headers in Salesforce connector:
- Go to Salesforce connector
- Advance tab -> Headers
- Enable Headers as Expression
- Pass the required header in a JSon Format
- Execute again
Use the below picture as a sample reference