You need to sign in to do that
Don't have an account?
Abhishek Singh 88
need help to populate lookup field using apex class
Hi developers,
Here i have written a class, which is inserting an incident and after insertion i am trying put id of that incident in another child object
Here i have written a class, which is inserting an incident and after insertion i am trying put id of that incident in another child object
BMCServiceDesk__Incident__c newincident= new BMCServiceDesk__Incident__c(); newincident.Name='Wellspan'; newincident.description__c='Test cases.' insert newincident; // second object related as lookup, incident__c is field related to it. email_to_incident_history__c emailincident=new email_to_incident_history__c(); emailincident.incident__c=newincident.Name; insert emailincident;But it is throwing an error, saying invalid id.
incident__c is a look up field into email_to_incident_history__c object right? Use below code. Let me know if this works :)
Thanks!
Amit Singh
All Answers
incident__c is a look up field into email_to_incident_history__c object right? Use below code. Let me know if this works :)
Thanks!
Amit Singh
You shoud try below updated code :-
I have updated line of code : emailincident.incident__c=newincident.Id;
If you feel my answer is work for you then choose as a best answer.
Best Regards - Nagendra
Since all answer are correct so i marked first one as best answer.