You need to sign in to do that
Don't have an account?
Tony Wiley
Auto-populate Account lookup field based on another field
On the Case object we have the standard lookup field to the standard Account object. I also added a field called "Login_ID__c". We have this same field (Login_ID__c) in the Account object as well. Now when the user enters a Login ID in the case object, based on the value in the Login ID field it should auto populate the Account lookup field because each Account record has a unique Login ID. I have tried using a workflow and process builder but to no avail. From what I’ve researched, I think it’s possible to do this with an apex trigger but I am not familiar with apex at all. Can anybody help me out or offer any insight? Thank you.
Please check once below sample code :
Hope this helps you!
If my answer helps resolve your query, please mark it as the 'Best Answer' & upvote it to benefit others.
Thanks
Varaprasad
@For Support: varaprasad4sfdc@gmail.com
Blog: http://salesforceprasad.blogspot.com/
Salesforce latest interview questions :
https://www.youtube.com/channel/UCOcam_Hb4KjeBdYJlJWV_ZA?sub_confirmation=1
All Answers
Please check once below sample code :
Hope this helps you!
If my answer helps resolve your query, please mark it as the 'Best Answer' & upvote it to benefit others.
Thanks
Varaprasad
@For Support: varaprasad4sfdc@gmail.com
Blog: http://salesforceprasad.blogspot.com/
Salesforce latest interview questions :
https://www.youtube.com/channel/UCOcam_Hb4KjeBdYJlJWV_ZA?sub_confirmation=1
Thanks for the quick reply, the code worked perfectly as intended. I have one more question though, every once in a while we have someone call into our support team who is a client of a client (so not actually our client but will be using our software to interact with our client) and therefore will not have an account with us but will have a Login ID to login to our system. Is it too much trouble to modify the code a bit to have it check to see first if there is an Account record with the given Login ID that’s typed into the case and if not, have it NOT run the trigger? What’s happening currently is when you try to create a case with a Login ID that is not associated with an Account record, the case creation errors out and doesn’t allow you to create the case. Otherwise it works perfectly.
Thanks a bunch,
Tony
If Login_ID__c is there in account it will update on the case. Otherwise, it will be null.
it will not through any error.
Hope this helps you!
If my answer helps resolve your query, please mark it as the 'Best Answer' & upvote it to benefit others.
Thanks
Varaprasad
@For Support: varaprasad4sfdc@gmail.com
Blog: http://salesforceprasad.blogspot.com/
Salesforce latest interview questions :
https://www.youtube.com/channel/UCOcam_Hb4KjeBdYJlJWV_ZA?sub_confirmation=1
Thanks for your help,
Tony