Set off Salesforce Project Guidelines – DZone – Uplaza

In lots of MuleSoft integration tasks, there’s a requirement to create lead or case data in Salesforce. Organizations sometimes use the lead project rule and case project rule to mechanically assign new leads or instances to the customers or queue.

Once we create leads or instances from MuleSoft utilizing the Salesforce connector, by default it doesn’t set off the project guidelines and doesn’t ship electronic mail notifications to homeowners.

This weblog describes the method of triggering Salesforce lead or case project guidelines and sending electronic mail notifications to homeowners when creating data from MuleSoft. We are going to assume that the salesforce project guidelines are already arrange and which get triggered when creating leads or instances from the salesforce UI. We might be specializing in triggering project guidelines in Salesforce when creating a brand new lead or case from Mulesoft. This weblog is not going to cowl the way to create project guidelines in Salesforce.

Background

Salesforce Project Guidelines

Project guidelines in Salesforce are used to mechanically assign a lead or case to the proprietor (person or queue).

Salesforce supplies two varieties of project guidelines:

  1. Lead project rule:  That is used to specify how leads are assigned to customers or queues.
  2. Case project rule: That is used to find out how instances are assigned to customers or put into queues.

When a brand new lead or case is created it triggers the project rule in addition to sends the notification electronic mail to the assignee if the ship electronic mail checkbox is enabled. For instance: Within the beneath screenshot, you may see two lead project guidelines. One is default and the opposite is a customized rule (Mule Project Rule) created for this weblog. Please observe that at a time just one project rule may be energetic.

Mule Project Rule

On this rule, leads are assigned to the homeowners primarily based on the situation for lead: nation, and after that electronic mail notifications are despatched to these homeowners because the ship electronic mail checkbox is true.

To know extra in regards to the salesforce project guidelines you may refer right here.

Answer

AssignmentRuleHeader

To set off the project rule from MuleSoft, AssignmentRuleHeader have to be specified within the salesforce connector for the desired project rule to be triggered. We are able to specify two varieties of AssignmentRuleHeader.

  1. useDefaultRule: It is a boolean sort and it must be set to true. This triggers the default (energetic) project rule. If that is specified, don’t specify an assignmentRuleId.
  2. assignmentRuleId: On this sort, we are able to go the ID of a particular project rule to run for the case or lead. The lead or case project rule may be energetic or inactive. The Project rule ID may be fetched by querying the AssignmentRule object. If that is specified, don’t specify useDefaultRule.

EmailHeaderTo ship an electronic mail notification to the lead or case proprietor as part of the project rule, EmailHeader with “triggerUserEmail” sort set to 'true' must be handed within the Salesforce connector.

Walkthrough

For the demo, we might be contemplating a use case the place leads are created in Salesforce utilizing MuleSoft. We might be utilizing the beforehand talked about ‘Mule Assignment Rule’ which assigns results in homeowners primarily based on the lead nation worth and sends electronic mail notifications.

Step 1

Add a mule circulation with the beneath connectors to create leads in Salesforce.

Step 2

Within the salesforceHeaders variable set the AssignmentRuleHeader and EmailHeader with the beneath syntax:

%dw 2.0
output utility/java
---
{
    "AssignmentRuleHeader": {
        "useDefaultRule": true
    },
    "EmailHeader": {
        "triggerUserEmail": true
    }
}

Right here, we’re utilizing the useDefaultRule possibility which is able to set off the default energetic lead project rule.

In case your requirement is to set off a particular project rule, we are able to specify the assignmentRuleId:

%dw 2.0
output utility/java
---
{
    "AssignmentRuleHeader": {
        "assignmentRuleId": "01Q5j000000p4xaEAA"
    },
    "EmailHeader": {
        "triggerUserEmail": true
    }
}

You will get the assignmentRuleId by working SOQL: SELECT id FROM AssignmentRule WHERE Title="Mule Assignment Rule"

Please observe that we have to go each the headers to set off the project rule and ship notifications. If the requirement is to solely set off the project and never ship an electronic mail, you may skip the EmailHeader. But when electronic mail notification is required it’s worthwhile to mandatorily add the EmailHeader else it is not going to ship an electronic mail even when the ship electronic mail checkbox is true within the project rule.

Step 3

Add the Salesforce transformation within the Rework Message.

%dw 2.0
output utility/java
---
[
    {
        "FirstName": "John",
        "LastName": "Doe",
        "Company": "XYZ Company",
        "Phone": "0123456789",
        "Email": "john-doe@xyzcompany.com",
        "Status": "Open - Not Contacted",
        "Street": "1, Main Street",
        "City": "New York City",
        "State": "NY",
        "Country": "US",
        "PostalCode": "10001"
    }
]

Please observe that we’re creating this lead with nation = ‘US’ which is able to fulfill the primary project rule situation and will assign this result in ‘Mule Max’.

Step 4

Move the salesforceHeaders variable within the headers part of the Salesforce connector.

Step 5

Run the appliance and set off the request.

Validation

  • Lead Assigned: A lead is created in Salesforce and it’s assigned to ‘Mule Max’ as per the lead project rule.

  • E mail Despatched: E mail is triggered to the lead proprietor as per the lead project rule.

E mail format may be completely different primarily based on the e-mail template used within the salesforce project rule.

Notice: In case you are utilizing the Salesforce Sandbox surroundings, it could not set off the e-mail notification as a result of by default the ship electronic mail entry is disabled in Sandbox. To allow the ship electronic mail entry go to the e-mail deliverability setting within the Salesforce setup and alter the entry stage to All E mail.

Abstract

We now have coated the way to set off the salesforce lead project rule and ship electronic mail notifications to the lead homeowners when creating new leads from MuleSoft. The identical course of can be utilized for the case project guidelines.

Share This Article
Leave a comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Exit mobile version