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
Sandrine94748Sandrine94748 

Trigger Asset before update | old map is same as new map

Hello,

I wrote a trigger on before update for Asset.
When it reaches to my trigger, it is already updated hence i am not able to make difference between Old map and new map..
Is there any way where i can ask my trigger to execute before other trigger..

This behavious is strange for me too..

thank you for any suggestions
Best Answer chosen by Sandrine94748
Amith RaoAmith Rao
Hi Kiran,
               oldMap  : IDs of Old Versions of salesforce object records.  Have Update & Delete Triggers
               newMap: IDs of New Versions of salesforce object records. Have before Update, after insert, after update & after undelete.
 1 object can use only ---- 1 Trigger (best recommendations)

But i am not sure whether you can Inactivate other trigger if not usefull pertaining to your requirement.

Regards
Amith S Rao

All Answers

Amith RaoAmith Rao
Hi Kiran,
               oldMap  : IDs of Old Versions of salesforce object records.  Have Update & Delete Triggers
               newMap: IDs of New Versions of salesforce object records. Have before Update, after insert, after update & after undelete.
 1 object can use only ---- 1 Trigger (best recommendations)

But i am not sure whether you can Inactivate other trigger if not usefull pertaining to your requirement.

Regards
Amith S Rao
This was selected as the best answer
v varaprasadv varaprasad
Hi Kiran,

Please check once below sample code:
trigger UpdatedContactNumoftimes on Contact (Before update) {
    Map<id, contact> oldMap = trigger.oldMap;
    system.debug('==oldMap=='+oldMap);
    
    Map<id, contact> NewMap = trigger.NewMap;
    system.debug('==NewMap=='+NewMap);
    
    list<contact> oldCons = trigger.new;
    system.debug('==oldCons=='+oldCons);
    
    list<contact> NewCons = trigger.old;
    system.debug('==NewCons=='+NewCons);

}
In above code trigger.oldmap and trigger.new map both are having different data in custom fields.
But coming to system fields both having same data like lastmodfieddate and created date and SystemModstamp etc.


Hope it helps you.
Please let me know in case of any other assistance.


Thanks
Varaprasad