You need to sign in to do that
Don't have an account?
jojo5
how to compare old values of eventrelation
Hi, can someone please show me examples of how to compare old and new values using the EventRelation Object? Is this even possible? I just want to get the old values of the isParent and isInvitee.
Below is what I was trying out, but it gives me an error.
Method does not exist or incorrect signature: void get(Boolean) from the type Map<Id,SObject>
for (EventRelation er: eLst) {
EventRelation oldOpp = Trigger.oldMap.get(er.EventId);
}
Below is what I was trying out, but it gives me an error.
Method does not exist or incorrect signature: void get(Boolean) from the type Map<Id,SObject>
for (EventRelation er: eLst) {
EventRelation oldOpp = Trigger.oldMap.get(er.EventId);
}
https://developer.salesforce.com/forums/?id=9060G0000005jRXQAY
To see if the value is changed or not we would need fields prior value in apex trigger. To compare the old value and new value in trigger we can use trigger a new map and trigger an old map. Basically, to compare old field value of record with the new value in trigger we need to access trigger. oldmap and trigger.
For further reference,
https://www.cloudforce4u.com/2013/07/compare-old-and-new-values-in-trigger.html
https://www.sfdc99.com/2014/02/25/comparing-old-and-new-values-in-a-trigger/
Thanks!
All Answers
Shadi Anudan (https://allgovtscheme.com/shadi-anudan/), PM Kisan (https://allgovtscheme.com/pm-kisan-yojana/), Meebhoomi (https://allgovtscheme.com/meebhoomi/), Banglarbhoomi (https://allgovtscheme.com/banglarbhumi-gov-in-land-and-land-reforms/), ekharid (https://allgovtscheme.com/ekharid-registration/).
Try the suggestions as mentioned in the developer blog,
https://developer.salesforce.com/forums/?id=906F0000000BY6yIAG
https://developer.salesforce.com/forums/?id=9060G000000XdimQAC
It might help you.
Thanks!
Thank you for your suggestion. I am new to salesforce development and trying my best to understand how this works, but I am afraid I am stuck and lost. I followed the links you provided and tried it in my environemnt. I just want to compare the old and new value so I can make an update. Will you be able to help me?
in my trigger i set the following:
if (Trigger.isBefore){
if (Trigger.isUpdate){
EventTrigger.eventUpdateContact(Trigger.oldMap, Trigger.newMap);
}
in my class I did the following
public static void eventUpdateContact(Set<Id> OldMap, Set<Id> NewMap){
List<EventRelation> eventLst= [SELECT isParent, isInvitee, RelationId
FROM EventRelation
WHERE EventId IN :NewMap
];
for(EventRelation e : eventLst){
if(OldMap.get(e.EventId).isParent == true && NewMap.get(e.EventId).isParent == true){
}
else{
}
}
}
i get errro: I get an errror Method does not exist or incorrect signature: void get(Boolean) from the type Set<Id>
https://developer.salesforce.com/forums/?id=9060G0000005jRXQAY
To see if the value is changed or not we would need fields prior value in apex trigger. To compare the old value and new value in trigger we can use trigger a new map and trigger an old map. Basically, to compare old field value of record with the new value in trigger we need to access trigger. oldmap and trigger.
For further reference,
https://www.cloudforce4u.com/2013/07/compare-old-and-new-values-in-trigger.html
https://www.sfdc99.com/2014/02/25/comparing-old-and-new-values-in-a-trigger/
Thanks!