I'm trying to make a script where the administration of the company gets an email of important changes on the company card. The logic behind it is finished, but im struggling with the different attributes of the triggers "Before saving company" and "After saving company".
In "Before saving company", the :org value of a User Defined Field is showed as the previously set value, and the normal value is the new value that it has been changed to. See below:
ContactEntity.CustomFields.SuperOffice:23 = [I:39]
ContactEntity.CustomFields.SuperOffice:23:org = [I:41]
And in "After saving company", the :org value will always be identical to the new value set.
ContactEntity.CustomFields.SuperOffice:23 = [I:39]
ContactEntity.CustomFields.SuperOffice:23:org = [I:39]
However, when using "Before saving company", the field "ContactEntity.UpdatedBy.X" will be linked to the last person that made changes to the company, not the person who is changing the company now.
I need the trigger to tell me the changes made, and who made these changes, but it seems i have to get this information from 2 different triggers.
Here is the script for extracting all the EventData from the triggers, both the TriggerScript for Before and After saving company are logically identical:
All Replies (4)
Hi Frederic
You could pass the ":org" value using ed.setStateValue() in the "before saving" trigger. This passes it to the "after saving" trigger, where you can pick it up with ed.getStateValue(). Then you can execute the rest of your logic there.
Espen
Alternatively, use the getActiveUser global method to get the associate id of the user making the change in the before save trigger
Would also like to see changes of the category of the Company. In the example below i changed from "Eksisterende kunde" --> "Potensiell kunde", and it only seems like the value of the Tooltip stays on the old value in the "Before trigger" script.
Before Trigger:
ContactEntity.Category.Id --> 2
ContactEntity.Category.Tooltip --> Alle eksisterende kunder skal vises her.
ContactEntity.Category.Value --> Potensiell kunde
After Trigger:
ContactEntity.Category.Id --> 2
ContactEntity.Category.Tooltip -->
ContactEntity.Category.Value --> Potensiell kunde