Ask Search:
Emily GrimmEmily Grimm 

Increment Value with Cross-Object Formula - Process Builder

Hello,

I am building a process flow that increments a custom callback counter field in the Lead object when a call is logged in the Tasks object.  

User-added image

I have selected field that I would like to update, but I am having difficulty writing the correct formula.  Based off of some previous searches, I found this help thread (https://developer.salesforce.com/forums/?id=9060G000000IBlWQAW )that suggested the formula [ObjectA__c].ObjectBLookup__c.ObjectB_Field__c + 1.  

I used [Task].WhoId.Callback_Count__c + 1 in the formula field, but got the following error.

User-added image

Any ideas as to why this formula is incorrect?
Best Answer chosen by Emily Grimm
Pratima ShriPratima Shri
The process builder should fire only on create. Otherwise it will calculate every time you edit a task.
Here is the flow:
User-added image
We will be passing whoIdLead from the process builder by using Fieed refernce Task.WhoId. Make sure Input/output type for whoIdLead is Input/Output
User-added image
User-added image
What you need to note here is {!sumOfCounter} is a formula variable which you need to create by clicking on Craeate New or from resources.
User-added image

All Answers

Pratima ShriPratima Shri
Hi Emily,
What object is your process builder on? Is it on Task and you are trying to increase the counter on lead based on the tasks created and Is the counter a number field?
I'm afraid for lead it might not be directly possible. I found this documentation.
https://help.salesforce.com/articleView?id=Process-Builder-Update-Related-To-record-from-Task-or-Event&language=en_US&type=1
Read this line: For Name To, this will work for those Contacts that are related to an Account, since a Lead is not related to an Account, it will not work for Leads.
Please let me know what you are looking to do so we can comeup with some ideas.
Emily GrimmEmily Grimm
Hi Pratima,

Thank you for finding that documentation!  Yes, I was using the Task object, then trying to update the counter, which is a number field. 

Within the same process, I was able to update the "Date of Last Call" field within the Lead object, while using the task as the object of the process.  I was hoping I would be able to update this second field within the same process, but it may not be possible.

User-added image

The end goal is to have a count of the total number of calls logged, to help stay on top of leads and generate metrics on how well we are following up. 
Narender SinghNarender Singh
Hi Emily,

You can create an autolaunched flow. Call this flow from your process passing the lead record ID to the flow as a parameter. Now your flow will do a query to find the lead record whose ID matches the passed parameter ID. Once the record is found you can increment the Call Counter field by 1. Then update the lead record.

And voila!

Let us know if you need any assistance with configuring the flow.
Pratima ShriPratima Shri
Yes you are able to update Lead fields but for your second scenario, you are actually trying to use the formula by accessing the Lead field from task to add it to 1. Which is not allowed.
Based on your requirement sounds like you need a rollup summary. 
One way to do this is writting a trigger on Task onject, if you are willing to go this route I can help u.
Next one is install an app from app exchange to use Rollup Helper to get rollup for objects which are not in Master detail. https://appexchange.salesforce.com/appxListingDetail?listingId=a0N30000009i3UpEAI
Pratima ShriPratima Shri
+ Narender
Flow would also be one of the routes you can take.
Pratima ShriPratima Shri
A flow actually worked for me. The only trick is create a formula within your flow and then assign it to the Lead counter field. Make sure you set the default valeu of Counter to 0 first. Let me know if you need screenshots.
Emily GrimmEmily Grimm
Thank you both for your replies!  I believe a flow would work best for this situation.  If you had screenshots, that would be extremely helpful!
Pratima ShriPratima Shri
The process builder should fire only on create. Otherwise it will calculate every time you edit a task.
Here is the flow:
User-added image
We will be passing whoIdLead from the process builder by using Fieed refernce Task.WhoId. Make sure Input/output type for whoIdLead is Input/Output
User-added image
User-added image
What you need to note here is {!sumOfCounter} is a formula variable which you need to create by clicking on Craeate New or from resources.
User-added image
This was selected as the best answer
Emily GrimmEmily Grimm
This is extremely helpful!  Thank you so much!