Soultion: We will create a flow which will look for Case with a Status other than Closed with the same mobile number of the Incoming SMS and attach it to the Incoming SMS with the help of Process builder.
Step 1: Create Case Status Field on Incoming SMS.
Case Status Field will be a Formula Field which will pick up value of Case Status in Text Format.value of Case Status in Text Format.
To create a formula field follow below steps:
Go to Setup
Search for Object in Quick Find Search Box and select Objects as shown below
Select Incoming SMS from the Object List
Click on New Under Custom Fields & Relationships List
Select Formula in Step 1
Name the field and select Text
Formula for the Case Status field will be “Text(smagicinteract__Case__r.Status)”
Save the Field
Step 2: Create a Flow
To create a flow you can go to Setup, enter Flows in the Quick Find box, then select Flows, and then click New Flow.
In this Flow we will need 3 Variable(Input/Output type = Input and Output) .
MobileNumber - Which will store the value from the Incoming SMS Record.
IncomingSMSid - Which will store the value of Incoming SMS Record id.
Caseid - Which will store the value of Case Record id.
For more details on Variables check this link
Flow will have 2 actions
Before creating any Action you will need to create variables to be used. To create variables click on Resource Tab on the Left Panel and Click on Variable and name the Variable.
Record Lookup: From Pallet Select Record Lookup from Left Panel and drag and drop on the Canvas
Select the Criteria as below:
2. Record Update: From Pallet Select Record Update from Left Panel and drag and drop on the Canvas
Select the Criteria as below:
Once you have create the flow you will need to select the block from where the flow need to start Select Record Lookup and Connect both the block as below Image. Click on Save. Once you save the Flow close the it and Activate the Version you just created.need to start Select Record Lookup and Connect both the block as below Image. Click on Save. Once you save the Flow close the it and Activate the Version you just created.create the flow you will need to select the block from where the flow need to start Select Record Lookup and Connect both the block as below Image. Click on Save. Once you save the Flow close the it and Activate the Version you just created.
After you finish all these steps Flow will look as below Image
For more details on Flow check this link
Step 3: Create a Process Builder
Once you have created the flow you will need to create a Process builder to pass values for the Flow.
To create a Process builder go to Setup, enter Process Builder in the Quick Find box, click Process Builder, and then click New. Name the process. The API name updates itself when you tab out of the Name field.
Click Add Object to associate your process with an object and specify when to start the process. For this process, choose Incoming SMS and start the process when the record is created.
Click Add Criteria.
Name the criteria .
Leave Conditions are met selected.
Set the first filter condition. The process needs to check whether the case status has been closed and case lookup on Incoming SMS is not null
Click in the Field box (1), choose smagicinteract__Incoming_SMS__c > the field you created on Incoming sms for case status , and click Choose.
For the operator (2), leave Equals selected.
For the type (3), leave String selected.
For the value (4), Closed.
5. Set the second filter condition. The process needs to check whether the opportunity is high-value.
Click Add Row.
Click in the Field box, select smagicinteract__Incoming_SMS__c > smagicinteract__Case__c, and click Choose.
For the operator, select Is null.
For the type, leave Booleanselected.
For the value, select False.
6. Click Save.
7. Now you need to define the actions that execute when the criteria are met. Here we need to call the Flow and add the Variables
Under Immediate Actions, click Add Action.
For the action type, select Flow.
Name the action.
Select the Flow you created in Step 2.
In Set Flow Variables select the Variables
In 1st Row Select IncomingSMSid >> Select Type as Reference >> Select Value as Record ID.
In 2nd Row Select MobileNumber>> Select Type as Reference >> Select Value as Mobile Number.
Click on Save
8. Click on Activate on the top Right Corner.