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
Edward Scott 5Edward Scott 5 

Copy the value of a field

Hi Community,

I am trying to write a trigger that will alert me when a value has increased or decreased by 10%. So currently we have a field called subscriber number and it keeps track of the number of people who receive a publication. I would like to copy that value to another field and hold it until the value of the original field goes up or down by 10%. 

Thanks for your help,

Edward
William TranWilliam Tran
Add logic to your trigger:

Here's a potential pseudo logic:

if Target field is blank (initial copy) then set Target = source.

If (Source > 1.1*Target or  Source <0.9*Target) then do your alerts.

Resetting the Target if desired.

Thx
Edward Scott 5Edward Scott 5
Thanks William,

The only problem I am having is actually copying the valuse of the Target field into the source field. When I say if Source is null then Source == Target I get an error. Do you have any advice on how to get it to equal?

Thanks again
William TranWilliam Tran
Can you post your code?

I think we are reversing our definition of source and target so lets use original and copy.

so field copy = field original.

Both fields should be on the same object.  Make sure the copy field is a editable field (not a formula or readonly field)

Since it is a trigger, the copy only only updated from the record is updated/added.

Thx