CRM
Query CRM
This example shows how to read CRM Contacts and send an email to each record returned.
First we use the Query CRM Entities action to to read the Email, FirstName & LastName columns from the Salesforce CRM Contact table. The results are returned as CSV text to the CSV variable (there is also the option of returning as Json or Markdown).
We then use the For..Each action to loop on each Line in the CSV variable.
Inside the loop we use the Parse CSV Line action to get the Email, FirstName & LastName values and assign them to variables.
We can then use the Send Email action to send an email.
Add Attachments To A Salesforce Contact
In this example we want to check each incoming email. If a contact record exists in Salesforce with the from address of the incoming email we want to add any PDF attachments to the Salesforce contact record.
First we use the Get CRM Entity action to lookup a contact from Salesforce where the Email field is equal to %Msg_FromEmail%. If a contact is found the %ContactID% variable will be assigned the Salesforce contact id.
If a contact is found (the %ContactID% variable is not blank), we start an If block.
Each attachment must be assigned an OwnerId, this is the id of the user that is adding the attachment. We need to use the Get CRM Entity action to lookup the user record to get the user Id.
Note: You could save the user id as a Solution Constant to save having to look it up each time.
We then use the For..Each action to loop on each attachment. And then the Update CRM Entity action to add a record to the Attachments table. The Body field of the Salesforce table is a binary type. For binary types, if the assigned value is a path the actual file contents will be read and assigned.