Update task due date when due date field on related record is updated - Answers - Salesforce Trailblazer Community
Trailblazer Community
Ask Search:
Daniel BennettDaniel Bennett 

Update task due date when due date field on related record is updated

I currently have a process builder fire off a task when a custom field equals due. But I am having issues changing the due date of the task when the field on the record is updated.

This is the field section on the record - Record is required to enter date when creating and stage is default at due

User-added image

In process builder, I have it setup as follows:

The process runs when a record is created (only) -  I had it to edited as well but I got duplicate tasks created no matter what field I updated.

Conditions: field must equal Due - I tried to have this have this run with the advanced rule of only fire when a specific field is updated but this field will stay due but the date it is due has changed so no new task is created.

Action: Create Task that has a due date related to record field.
User-added image

At the basic level, I want the task due date to be updated when the related record field due date is changed. Hope someone is able to help.
Steve DoddSteve Dodd
Hi Daniel,

Are you using standard Salesforce (WhoId, WhatId) to relate the object in question, or did you build a custom relationship between the two objects ?

What I'm getting at is this...

If you're trying to tell Process Builder to make an assessment based on a field in the related record, then you can't do that using the WhoId (Name) and WhatId (Related To) fields in the Task record.
Daniel BennettDaniel Bennett
I do think they are related and I believe they are custom.  New to salesforce so not 100% sure. We are using a third party salesforce system called propertybase. Not sure if that helps.

I tried setting up another process that fires when a record is changed or edited that checks whether the due date field was changed and then updates that task that has the type set to a specific value. It doesn't seem to work though... Here are the screenshots of what I created.

User-added image
User-added image 

I don't mind the previous task not being deleted so if there is a way to just create a new task maybe I should just go this route. 

Any thoughts are greatly appreciated!  
Steve DoddSteve Dodd
That process doesn't look like it will work... 

Is the [pba__Closing...cantreadtherestofit Field a field on the object to which the Task is related ?

I would create a lookup relationship field on the Task object (Activity Custom Fields) that looks up to that object...providing you are not already at the limit of 20 Activity fields. Then, setup a PB process that populates the field using the WhatId in your Task. Once you have that, and a value is being stored in that field, you can build another process that tells it to look at a field value in the record you linked to the Task through the lookup relationship, and then use an immediate action to update your Task as needed.
Daniel BennettDaniel Bennett
Okay. I am not sure I can do the lookup relationship when I have multiple fields where dates are changes and due date of tasks should change. Maybe I am misunderstanding how I would create the lookup field in my situation.

I have multiple fields on the [pba__closing] record that may or may not get updated upon there creation.
User-added image
The dates sometimes change. So I need either; a- update task that is originally created by the process b- have a new task created with the new date. 

In the process I created for [pba__closing].intent_to_proceed_Stage/DueDate I had the following logic create a task
 
IF [pba__closing.intent_to_proceed_Stage] = Due
     CREATE RECORD (Record Type = Task)
The Task has a custom field (Activity Custom Fields) called "Related To ID" which I have the value set to [pba__closing].Id (This has the Intent to proceed due date custom field that changes). This is I believe is what you are referencing in terms to the WhatID
User-added image 
I also have the whoID for who the task is related to contact, but I don't think this effects my due date changing issue 

I just wish there was a way to have a task date be dependent on a field that is related to the task. Thanks for the help and appreciate any ideas you may have.
Steve DoddSteve Dodd
WhatId is just that - "what" object the Task is related to
WhoId is "who" the Task is related to - this can only be a Lead or a Contact

Is the custom "Related To ID" Activity field that you created just a Text field that stores the ID of the related object (or a formula field that displays a calculation of the value as Text), or is it a Lookup field to the pba__closing object ?

Let me back up one step because I want to be sure I understand exactly what you're trying to do...

1) A Task is created (either manually or through a separate process) and that Task is related to a custom object called pba__closing
2) If the value in either the Attorney Review Target Date or the Intent to Proceed Due Date on the related record is changed, you want to update the Due Date in the Task

Is that correct ?

And you can make the Task due date dependent on a field in a record that is related to the Task, as long as you have the relationship between those two objects setup the right way.
 
Daniel BennettDaniel Bennett
I am not sure where I would be able to check what the "Related to ID" stores. I am still new to Salesforce but with some guidance, I can find it. But I do believe it is a lookup to the pba__closing object.

You are hitting the nail on the head with what I am looking to accomplish. Appreciate all the help
Steve DoddSteve Dodd
Understood...and no worries, we all started somewhere.

Give me a few minutes and I'll build this in my dev org the way I think it will need to work, and then once I've tested it...I can show you some screen-shots and we'll compare notes.
Daniel BennettDaniel Bennett
That would be great! Thank you
Steve DoddSteve Dodd
All right...sorry, that took a little longer than I wanted it to...I got pulled away for a few minutes because of an emergency with some marketing automation software - that stuff can get pretty crazy.

Anyway, I was able to get this to work...I had originally planned to use two separate Process Builder processes, but I ended up using three. Let me give you the breakdown of how I did it, and how it's working, and we can take it from there.

First, I created two custom Activity fields - I'm displaying them on the Task layout in my dev org so I can see them, but there really is no need to display them on the page layout.

Field # 1 - Lookup to the pba_closing object

User-added image


Field # 2 - Date Change (Checkbox Field)

User-added image
Steve DoddSteve Dodd
Next, I created a process using Process Builder that starts on the Task object (only when a record is created)

if the Task is related to a pba_closing record (this is our WhatId), then I'm updating the custom pba__closing Activity field on the Task with the ID of the record in the Related to ID (WhatId) field on the Task:


User-added image


User-added image



User-added image

* Note use the first three characters of the record ID for your custom object in the formula - my happened to be a1m when I created it, but it should start with a1...something

You can also do this step like this if you prefer:

User-added image

 
Steve DoddSteve Dodd
Screen-Shot for the immediate action on that first process:

User-added image
Steve DoddSteve Dodd
So now, anytime a User creates a Task that is related to a pba_closing object, PB will establish a custom relationship between the two objects that you can utilize in Process Builder.

The second process starts on the pba_closing object (when a record is created or edited)

And it updates the 'Date Change' checkbox on the Task if a date is entered into either the Attorney Review Target Date field or the Intent to Proceed Due Date field.


User-added image

User-added image

User-added image








 
Steve DoddSteve Dodd
The action that updates the checkbox field on the Task has to be a scheduled action (not an immediate action) - you can't expect Process Builder to update the child record at the same time you are saving a value in the parent record

User-added image



User-added image


User-added image

IMPORTANT: This action will update the checkbox field on all tasks that are related to the pba_closing record, so I'm going on the assumption that you only have one Task per record.






 
Steve DoddSteve Dodd
Now that the Task has a box that has been checked (it will probably take 1 to 5 minutes after the previous action)...you can use a third process that goes back into the Task and changes the Due Date field.

Start the process on the Task object (when a record is created or edited)

User-added image



User-added image




User-added image




User-added image


HERE IS THE FORMULA FOR THAT LAST PART:
 
IF(
NOT(ISBLANK([Task].pba_closing__c.Attorney_Review_Target_Date__c)) ,
[Task].pba_closing__c.Attorney_Review_Target_Date__c,
[Task].pba_closing__c.Intent_to_Proceed_Due_Date__c
)

 
Steve DoddSteve Dodd
So that's one way to make it work...it says IF either of the pba_closing dates are changed from a null value to an actual date, then the Task due date should be updated to match the date that was entered.

If your use case says the Task also needs to be updated anytime an existing date in one of those fields is moved up or back...OR...if you could potentially enter both dates at the same time (with two different date values), then it would need to be tweaked to accomodate that.
Daniel BennettDaniel Bennett
Just getting into this now. I am understanding the process you created. The only thing is I have multiple multiple tasks on the pbe_closing record. Which you said was an important point in this process. Is there any way we can get it to work with multiple tasks on the record?

All of this documentation has been great! Really do appreciate how awesome the Salesforce community is. I will keep working this out in my system.

Thanks
Daniel BennettDaniel Bennett
This is the page layout format I was hoping to use to have task created based on these fields criteria
User-added image
Steve DoddSteve Dodd
The only thing with using multiple Tasks is you would have to have a way to differentiate the relevant Task from the other ones. When you are in the 'Update Records' action, you can use Updated records meet all conditions as your Criteria for Updating Records

...then find something in the relevant Task record (or records) that is distinct from the others like the Subject or the Owner or the Task Type and specify that in the Action as must have for updating the Task

(Filter the records you update based on these conditions)


User-added image



 
Daniel BennettDaniel Bennett
Sorry, it took so long to get back to you on my progress. 
I am getting hung up on the last part of the actual update of the task. I am not seeing an update happen.

The closing record Intent_to_proceed_date is created right away which gives the task a due date by defining values in a process that created the task. So when the task was created the date_changed is TRUE right away. Even when I add a new date the same issue occurs where the date changed button equal TRUE so when I update the field it doesn't fire off the process to update due date on the task.

This is where I think I get hung up by already having the date changed checkbox is defaulted to TRUE means then the process that is started by creating or editing a doesn't happen because the checkbox was the change on the task. So hopefully we can find a different way.

Closing WhatID was correctly added so we're good there. 

I have multiple fields on the closing record so I have criteria for updating records as the task.subjects string = the specific task. 

Otherwise, I think I have everything setup correctly just need to tweak the process to allow for dates changing on the closing to fire a process to change task due date. 

Thanks for everything Steve!
 
Steve DoddSteve Dodd
Do you want to keep plugging away at it and let me know if you get stuck...or do you want to continue doing some troubleshooting with it ?
Daniel BennettDaniel Bennett
If you could expand more on how I would set up the process to be able to work with the custom date field on the closing changing and the system recognizing this change after it was first created.

I am stuck on how exactly I tell the process on the task object to change the date to fire off and be updating the right task. 

I understood the process of the checkbox I just don't think that would work for the date being changed multiple times.
Steve DoddSteve Dodd
You can use the ISCHANGED function and tell the action to fire if either the Attorney Review Target Date or the Intent to Proceed Due Date is changed (you might want to throw "not isblank" in there as well), but you wouldn't be able to use the Advanced checkbox when setting the criteria:

User-added image

Something I've done before to accomodate multiple changes happening at different times like that is to have the original action check the box, and then have the action in the follow-up process 1) update the Task record the way it needs to be updated AND 2) un-check the box in the Task as a second action. That way, your Task record is tee'd up and ready to be flagged again when your process on the Closing record determines there is another change.
Daniel BennettDaniel Bennett
Okay, what is the immediate action that should follow this? Can I update the record now or do I need to trigger another process that is on the task object to start?
Steve DoddSteve Dodd
The immediate action is just whatever you want to do in the Task record - we had talked about changing the Task due date. Did you also want to automate another action in the Task ?

If you are doing something else to the Task, based on something happening in the related pba_Closing record, then you don't need to do any setup work for that since you have already established a relationship between the two objects. You would either add another action to your existing process...or add another criteria node plus an action to that process if the criteria is different than what you have already.

If that's not clear, if you can give me some more details on what you're trying to do, I may be able to talk you through it.
Daniel BennettDaniel Bennett
Okay let me break it down a little further to what I have and maybe you can better address what I am trying to do

Process - Creation of Task
This is how I am populating the task when a closing is only created. The following criteria and actions.
User-added image
User-added image
User-added image


 
Daniel BennettDaniel Bennett
Process - Update Related Task
Next, I have a Process to check on whether the field on the closing has changed.
User-added image
User-added image
User-added image

Hopefully, this sheds some light on what I have and what I am trying to accomplish a bit better.
Steve DoddSteve Dodd
OK, so Process # 1 is creating a Task (call it a Follow-Up Task) with pba_Closing as the parent Object whenever a picklist value on a pba_Closing record is "Due" - then your action is just assigning the field values in the Task.

QUESTION HERE - Will the 'Intent to Proceed Due Date' always be entered when your "Intent to Proceed" Stage is "Due" ? I'm assuming so, otherwise this process wouldn't fire.


For Process # 2, you're telling it to update records downstream - update the child record if something happens in the parent record....and you're specifying that it should update all child Tasks for that record that are of a certain "Type" - no issues with any of that so far.

NOTE: Don't use a Field Reference to set the new field value for your Task Due Date - use a Formula instead:

Field = Due Date
Type = Formula

Value =
[Task].pba_closing__c.Intent_to_Proceed_Due_Date__c

User-added image

User-added image


 
Daniel BennettDaniel Bennett
Okay, I think I found where your process is different from mine.

Me second process starts with the closing object, not the task object. I am not understanding/don't know how I can trigger the process that starts with task object when it is created or edited. when the edit/change happens on the closing object.

What I did was have the process start on the closing object and then update a related record like below. 
User-added image

Let me know your thoughts. Thanks
Steve DoddSteve Dodd
You can still start the process with a Closing record. You just can't say start with Closing and then when something happens in a Closing record do an immediate action in a child record. Your process starts on the parent and Process Builder doesn't update downstream in one step like that, so you may need to try scheduling the action.
Daniel BennettDaniel Bennett
Okay, but in order to get it to have the ability to schedule, I have to either have it only be when the record is created which won't work or define criteria with advanced button checked but I cant have it checked because I am using a Is changed. How would I work around this?
Steve DoddSteve Dodd
The only way that would work is if you can somehow flag the pba_Closing record when that happens, then use a process that goes back into the Tasks and make the changes. But that's where Process Builder starts to push back on you...it doesn't like to kick off a process based on a separate process, if both processes use the same starting object. That's why I like to update checkbox fields with workflow and execute follow-up actions with a process.
Steve DoddSteve Dodd
Build your workflow rule like this...then use a process to update the child records PLUS un-check the box in the parent record when it's done, so it will work the next time the date changes.


User-added image



User-added image


 
EdEd (salesforce.com) 
Hello everyone, 

Here is an article created to guide those who may have similar concerns:
https://help.salesforce.com/articleView?id=Process-to-update-Task-Due-date-from-related-record&language=en_US&type=1

Thank you all for your contribution to the community!
Lewis HowelLewis Howel
Just for anyone picking up on this now, the above article gives a 404 error..... However, just use Lightning Flow now it can be triggered from the record change directly, or if not so sure, create a sub-flow that process builder will trigger.