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
SARAESARAE 

How to update a field based on different objects?

Hi,
I have 3 objects : Payment, Opportunity, and Device.
The relationship is: Payment ---(Master-Detail)-- > Opportunity <--(Lookup)--- Device

What I'm trying to do is: When PaymentFieldStatus is edit, Update the related DeviceFields.

I tried to make a formula field on the device that shown me the "PaymentFieldStatus" and whan the value will change, update DeviceFields.
But the Workflow dosen't work on formula fields (because they not edit manually).

What more should I try?
Gyanender SinghGyanender Singh
Hi SARAE,

As per my understanding you have three object:

1. Opportunity
2. Payment
3. Device

On payment you have a master-detail relationship on Payment i.e. Opportunity is master and Payment is detail.

You have lookup relationship between Opportunity and Device i.e. Opportunity is Parent and Device is child.

You want to update device field on changing of field in the Payment.

So this not be done in Salesforce because you can only update Opportunity field on changing in the payment object but you can not update the device field on changing in the opportunity field.

So you can achieve the solution of your problem by using the code.

Thanks 
Gyanender Singh
SARAESARAE
Hi Gyanender Singh,
Thanks for the answer... Can you give me plz an example for a code like this?
Gyanender SinghGyanender Singh

Hi Sarae,

For this you have to write a trigger in device object and create a map between opportunity and payment and by using inerr query get all the payment related to that opportunity.
Later on create a for loop in device object and in the update device field insert the value of the payment field that is in the map between the opportunity and payment.

Thanks & Regards
Gyanender Singh