You need to sign in to do that
Don't have an account?
amruta_dhumal
How to set fieldvalue to it's priorvalue on recordtype change
Hi
I've Account & opty object.opty shared 22 recordtypes.when opty recordtype status is 'xxx' then it's updating Account field value to 'xxx' through trigger.
Now when I change recordtype to another [thru Change Link option beside recordtype] then it should set 'None' value on previous recordtype related Acct field.
Any suggestions how this can be achievable?
Amruta
Why would the previous record type be "None" when you switch from one record type to another one? Wouldn't it be the old record type? If you just want to clear the value in the related Account field, use null in your trigger.
Accountfield__c = null;
Actually my req. is old recordtype value should be update with new recordtype status value.
If new RT value is 'xxx' then it will update Account field 'status1' as 'xxxx',at that moment old RT value for that Acct field 'status2' is also set as 'xxx'.
Amruta
got it. In an update trigger, you can use the trigger.oldMap() to get the prior value.
trigger.oldmap.get(odbj.Id).fieldname
but how I can identify through trigger that recordtype is changed??
Amruta
you can compare the current value to the one in oldmap.
if "l" is the object in your trigger, then
if (l.RecordType != trigger.oldmap.get(l.Id).RecordType) {
}