function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Diane RoyerDiane Royer 

WorkFlow to Update Fields and Objects

Hello,
I am very new to setting up work flows in Salesforce.  I have worked my way through a text book about the flows, but am having difficulty setting one up.  I want to set up a work flow that I can schedule and have it update all of the records where a major is requested to be changed.  We have a field called Program that houses the student's major and a field that is Change Major To if the student changes his or her mind before applying.  I need the work flow to update the Program field to the value that is in the Change Major To field and then change the Program field in all corresponding Stage Histories.  I got the flow to loop through all of the students, but I can't seem to get it to go through a second loop to update all of the students' stages.  I have attached a snapshot of the flow for you to see. 
Any help would be appreciated.
User-added image
Syed Insha Jawaid 2Syed Insha Jawaid 2
Hi Dayne

What is the need to update stage history?
You would have enabled field tracking on that object of that field but what is the need to change it in history?
Can you please explain the requirement so that i can help you better.

Cheers!!!
Diane RoyerDiane Royer
The data in the Stage History is sent to a separate program.  As a result, the correct Major needs to be sent to that program as well.
Syed Insha Jawaid 2Syed Insha Jawaid 2
In order to query the history of any object you can use the following query : 
SELECT ParentId, OldValue, NewValue, Field, CreatedById, CreatedDate FROM Customer_History where parentId = <RECOrD_ID> and Field = <FIELD_NAME>
And then you can forward the result to the program with the new value.

Cheers!!!
Diane RoyerDiane Royer
Thank you for the suggestion.  I have actually been able to get the new value that I need, I'm having trouble getting my flow to loop through all the places that need updated.  It seems to run through once, but that's it.  Is there a way to get the loop to go through each record and field that needs updated?
Syed Insha Jawaid 2Syed Insha Jawaid 2
Hi Dayne

The Loop element in flow iterates through each element its just you need to check whether all the records are queried and you are using fast lookup tor return collection of stage history.

Cheers!!!
Diane RoyerDiane Royer
Thank you for the information. The flow is now working as is needed. I have one more question though. Could you tell me if it is possible for a flow to mark a task as complete? I would like this task to mark all “Update Major” tasks as complete when it is finished. Thank you, Diane Royer
Syed Insha Jawaid 2Syed Insha Jawaid 2
Hi Dayne

You need to update the task status as 'Completed'.

Cheers!!!