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/updated 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.

Kindly let me know if any further inputs/clarifications needed on my question.

Any advise/suggestions/help will be greatly appreciated

Many thanks in advance

Thanks & Regards,
Harjeet
Pradeep SinghPradeep Singh
Hi Harjeet,

You can achieve this using process builder or Trigger on Order Object and use the below criteria :-
ISCHANGED(Order_Status__c)  && Order_Type__c = "Upgrade Order". Use API name fo your fields.
 
Maria22Maria22
Thnaks Pradeep for your response.

Yes I do aware about the same which you mentioned in your reply.But my problem is how could I know the recently created Order with Order Type= Upgrade Order and status of that Order should be copied to Accounts' field OR How can we determine when a stage/status is changed for Order with Order type=Upgrade Order. Keepin in mind we can have multoiple Orders on accounts with different Order Type values but we need to only consider whenever a recenly Order created with Order Type= Upgrade Order then status of that Order should be get copied to Account's field or whenever status/stage of an order which belongs to Order Type=Upgarde Order is getting changed then also status/stage value of that particulat Order should get copied to Account's field.

Kindly advise/suggests whether the solution provided by you really fits into my use case or kinldy let me know if you need any further inputs/clarifications on same

Mnay thanks in advance
Maria22Maria22
Pradeep-I checked and found that only when recently created Order with Order Type= Upgarde Order then status of that particular Order is geetting copied to Account's field OR when the status of same(recently created) order with Order Type=Upgrade Order is modified then modified status value is getting copied to Accounts field. This is half of the requirement which I already implemented earlier.

My issue is stage of order where order type=upgrade order should also be copied if that order is already existing.Not should be restricted to recently created one only.Currently PB criteria works only during
1.when new Order with Order Type= Upgrade Order is being created then status of the order is getting copied to Account's field
2. Whenthe status of  same/recently created order type=upgrade order got changed and then new status value is getting copied to account's field.

But when I tried to change the status of another existing Order with Order Type= Upgrade order(not the existing one) then new status value is not getting copied to account's field

Any pointers will be valuable and welcomed

Mnay thanks in advance

Thanks & Regards,
Harjeet
Pradeep SinghPradeep Singh
I think this should work. I didn't get the scenario where this is not working. Can you post the details/snapshot of what you have implemented ?
Maria22Maria22
Hi Pradeep,

Thanks for your response.

I have created one PB on Order object with everytime created or edited as shown i below screenshots:

User-added image

In criteria box I have provided formula something like below:
AND(
ISPICKVAL([Order].Type, 'UPGRADE ORDER'),
[Order].Account_RecordType__c  = '012E0000000dZ7h',
OR(
ISNEW(),
ISCHANGED([Order].Status)
)
)

User-added image

I have triggered an Immediate Actions with Record related to Order and setting Upgrade Order Status field on account to Status field of Orders

User-added image

As I already mentioned PB is working for when I am creating new Order and status is getting copied to account's field OR when I am changing the status of Order then also status is getting copied to account's field. But its is working only for the recently cretaed Orders.It is not working when I tried to change the status of an older Orders with Order type= Upgarde Order then status is not getting copied to Account's field.

Any help/advise will be greatly appreciated

Many thanks in advance

Thanks & Regards,
Harjeet

 
Pradeep SinghPradeep Singh
Hi Harjeet,
Everything seems to be fine. Please check the recordtype of the old records that you are changing.
Maria22Maria22
Hi Pradeep,

I checked the record type of old record which I am changing.Its same.

Actually I create 2 orders with same record type and with Order Type= Upgarde Order.So status is getting copied to account's field on insertin of these orders respectively.Now when I tried to change the status of 1st order having the same record type as of second one and with Order Type=Upgrade Order then status of recently modified order is not getting copied to acccounts' field.

Only status of recently created order with Order Type= Upgrdae Order is getting copied.
Status of recently modified Order with Order Type= Upgrda eOrder is not getting copied.

Kindly help.

Any help will be greatly appreciated

Mnay thanks in advance

Thanks & REgards,
Harjeet
Maria22Maria22
Hi Pradeep,

I again cross checked and found that insertion status is happening correctly but updation is happening on last element in the list. I mean to say the status which is getting copied to account's field = last order's status even if I tried to modified the order which was created before the last one