You need to sign in to do that
Don't have an account?
Jyosi jyosi
Trigger to Copy the old value from one field to another field
Hello Everyone,
i need to copy the old values(Look up field into another field ).
Here whenever i save the record its getting the new id value in another field.
I need to excute this part of code whenver this feilds changes QCC_DSP__c/QAM_DSP__c
Suppose if the field changes happens on any other field is part of code should not execute.
public void onManagerUpdate(List<Contact> contactList) {
set<Id> CntIds= new Set<Id>();
for (Contact Mancontacts : contactList){
if (Mancontacts.QCC_DSP__c != null || Mancontacts.QAM_DSP__c!=null)
{
Mancontacts.Manager_Login__c = Mancontacts.QCC_DSP__c;
Mancontacts.Manager_Login__c = Mancontacts.QAM_DSP__c;
Mancontacts.QAM_DSP_End_Date__c=system.today();
}
}
//update ManagerUpdate;
}
Thanks for all the help.
Regards,
Jyo
i need to copy the old values(Look up field into another field ).
Here whenever i save the record its getting the new id value in another field.
I need to excute this part of code whenver this feilds changes QCC_DSP__c/QAM_DSP__c
Suppose if the field changes happens on any other field is part of code should not execute.
public void onManagerUpdate(List<Contact> contactList) {
set<Id> CntIds= new Set<Id>();
for (Contact Mancontacts : contactList){
if (Mancontacts.QCC_DSP__c != null || Mancontacts.QAM_DSP__c!=null)
{
Mancontacts.Manager_Login__c = Mancontacts.QCC_DSP__c;
Mancontacts.Manager_Login__c = Mancontacts.QAM_DSP__c;
Mancontacts.QAM_DSP_End_Date__c=system.today();
}
}
//update ManagerUpdate;
}
Thanks for all the help.
Regards,
Jyo
All Answers
Regards,
Jyo
public class MyClass{
public static void TestMethod(){
//Your code in the class
}
}
//TRIGGER CODE:
Trigger testTrigger on Account(before insert){
MyClass.TestMethod();
}
I am trying to call an Apex method from Process builder to update a ProfileID='System Administrator' with a field value in LastProfileId that changes every time we edit a user profile to system admin, actually through a formula it poulates with user last profile.My question is how to refer this fileld in my code?
Profile p = [select id from profile where name='System Administrator'];
for(User u:users){
u.LastprofileId= p.id;
}
update users;
In my code where I have mentioned 'LastProfileID__c', I need guidance is it right way to refer a field which has a dynamic value evertime a user is edited.