You need to sign in to do that
Don't have an account?
Omo Phalayi
Update Field based on recordtype in Salesforce using Apex
Hi All,
Please, I am trying to update an account field using a trigger based on recordtype. The requirement is if the Reocrdtype is AccOneA and the Active field on the Account is "Yes" update the description.
Please see my code below
trigger AccountTriggerB on Account (before insert, before Update) {
for(Account Acc:Trigger.New){
if(Acc.RecordType.DeveloperName=='AccOneA' && Acc.Description ==Null){
Acc.Description ='Please lets us know if there is any concern.Thanks';
}
}
}
Please, I am trying to update an account field using a trigger based on recordtype. The requirement is if the Reocrdtype is AccOneA and the Active field on the Account is "Yes" update the description.
Please see my code below
trigger AccountTriggerB on Account (before insert, before Update) {
for(Account Acc:Trigger.New){
if(Acc.RecordType.DeveloperName=='AccOneA' && Acc.Description ==Null){
Acc.Description ='Please lets us know if there is any concern.Thanks';
}
}
}
Greetings to you!
When you are going through a loop in a trigger you don’t have access to Record Type name like RecordType.Name, you can only access Id as RecordTypeId.
Please try the below code, I have tested in my org and it is working fine. Kindly modify the code as per your requirement.
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas
All Answers
Greetings to you!
When you are going through a loop in a trigger you don’t have access to Record Type name like RecordType.Name, you can only access Id as RecordTypeId.
Please try the below code, I have tested in my org and it is working fine. Kindly modify the code as per your requirement.
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas
The solution works
Right now I am working on a requirement where we have to automate a process to grant temperory login access to users with System admin privilages for specified period of time. I have followed a process explained in a blog https://jenwlee.wordpress.com/2015/08/23/how-to-use-flow-and-process-builder-to-temporarily-grant-system-admin-rights-to-a-user/. I followed the process but didnt get the expected results , any thoughts would be appreciated.