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
Maria22Maria22 

Update Account's Field based on recently created or updated any exiting related records based on specific criteria(s)/condition(s)

Hi All,

I hope everyone is doing good. I turned up here for a valuable advise from all of you experts.

My usecase is as below:

We have 2 objects "Accounts" and "Orders". I need to update one field on account object called as "Upgrade Order Status"(API Name- Upgrade_Order_Status__c) which is a text field with the value of "Order Status" field of only that Order where new Order is being created as Order Type = 'Upgarde Order' or an already existing order with Order type='Upgarde Order' and status is getting changed.

Order type is a picklist field on Order object having multiple values in which "Upgrade Order" is one of among them. Account can have multiple Orders with different Order Type.But my use case is to populate account's "Upgrade Order Status" field with the Order status field value of recently created order having order type= "Upgarde Order' OR there is a change in Order Status field of an already existing Orders of type "Upgrade Order".

Illustartion:
Account Name: Account Demo
has 5 Orders with different Order Type
1. Order1 with Order Type= "ABC" with Order Status= "New"
2. Order2-with Order Type= "Upgrade Order" with Order Status="Open"
3. Order3 with Order Type= "XYZ" with Order Status="Open"
4. Order4 with Order Type="Upgrade Order" with Order Status= "New"
5. Order 5 with Order Type="ABCQRS"with Order Status= "Closed"
So we need to populated "Upgrade Order Status" with the status value of recently created/changed Orders's Status where Order Type= "Upgrade Order".So if suppose among 5 above mentioned orders if Order 4 is recently created  orders with Order Type="Upgrade Order" then "Upgrade Order Status" on account should be populated with value "New" because Order 4 is having Order Status= "New".
In case if we modify Order 2 and changed the status from "Open" to "Closed" then "Upgrade Order Status" on account should be populated with value "Closed" because Order 2 is recently modified order with order type=Upgarde Order.

Solution which I tried:
I created one Process Builder on Order Object with everytime ceated or edited with Criteria like mentioned below:

((ISNEW() && ISPICKVAL([Order].Type, 'UPGRADE ORDER') && [Order].Account_RecordType__c  = '012E0000000dZ7h' ) || 
(ISCHANGED([Order].Status )  && ISPICKVAL([Order].Type, 'UPGRADE ORDER') && [Order].Account_RecordType__c  = '012E0000000dZ7h') )

My Current Issue:

But it is working only for recently created Order with Order type= Upgarde Order and status of that Order is getting copied to Account's field OR When the status of same Order I mean recently created Order with Order Type= Upgrade order then new status value is getting copied to Account's field. This is just the half of my requiremnt done. Infact I also want the status of any other existing Order with Order Type= Upgrade Order is getting changed then the new value shhould be copied to Account's field. Currently only for the Order with Order Type=Upgarde Order which is craeted latest or when the same latest Order's status is modified then Account's field is updating

Is there a way I will be able to succefully update "Upgarde Order Status" with the status value of Order with Order Type= Upgrade Order when that Order with Order Type=Upgarde Order is either recetly created OR whenever any other existing Order's staus  with Order Type=Upgarde Order is getting changed(not just the latest created one) then the same status value should get copied to Account's "Upgrade Order Status" field.

Any valuable suggestions/inputs are greatly appraciated

Many thanks in advance