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
TilluTillu 

How to compare 2 object fields?

I have  "price" field in one object,  and i have  "Amount" field in other object. So now i want  to compare  "price"  value within 10% of the associated object record’s  "Amount" . If the match occues then i need to update a field. But how to compare these fields for 10 % .
Best Answer chosen by Tillu
Sonam_SFDCSonam_SFDC
Ok..using SOQL you can get the value of Amount field(and the other can - the vale of price field) from the other object as you mentioned that these two records in the objects will be associated.

Once you get the value in the trigger - you can then compare using
if (pricevalue <= (10*Amount value)/100)) {update the field}

Hoping I'm able to understand your requirement..

All Answers

Vinita_SFDCVinita_SFDC
Hello,

Are these object related? If yes, then you can setup a workflow for this requirement.

If not, then set up relationship first and then create a workflow with action field update.
Sonam_SFDCSonam_SFDC
Hi,

You can write a trigger on both the objects to check if whenever the price and amount field are updated - the 10% rule is checked and the corresponding field can be updated.
TilluTillu
Ohhhhh, I know that i want the logic of 10%
Sonam_SFDCSonam_SFDC
Ok..using SOQL you can get the value of Amount field(and the other can - the vale of price field) from the other object as you mentioned that these two records in the objects will be associated.

Once you get the value in the trigger - you can then compare using
if (pricevalue <= (10*Amount value)/100)) {update the field}

Hoping I'm able to understand your requirement..
This was selected as the best answer