You need to sign in to do that
Don't have an account?
Hari nadh babu Eluru
Trigger Apex getting nullpoint exception
Hi there !
In this Trigger Apex, Nullpoint Exception was getting
The code that i was did is as below
In this Trigger Apex, Nullpoint Exception was getting
The code that i was did is as below
trigger SignIn_Trigger on Sign_In__c (after insert) { list<Sign_In__c> i = [select Current_Password__c, New_Password__c,Student__r.Email__c, Password__c, Username__c from Sign_In__c where id IN:trigger.newMap.keySet()]; for(Sign_In__c s : i){ if(s.Student__c != trigger.oldMap.get(s.Id).Student__c){ system.debug('Name is'+ s.Student__c); String userEmail = s.Student__r.Email__c; Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); String[] toAddresses = new String[] {userEmail}; mail.setToAddresses(toAddresses); mail.setSubject('Your Password is updated' + ' So#- '+ s.New_Password__c); String body = 'Your Password is' + '-' + s.New_Password__c; mail.setPlainTextBody(body); Messaging.sendEmail(new Messaging.SingleEMailMessage[]{mail}); } } }While i'm inserting record the error was getting the image is error as below
Apex trigger SignIn_Trigger caused an unexpected exception, contact your administrator: SignIn_Trigger: execution of AfterInsert caused by: System.NullPointerException: Attempt to de-reference a null object: Trigger.SignIn_Trigger: line 4, column 1Please resolve the issue and provide the solution for it. Thank you !
Can you please try with below code.
If this helps, please mark it as best answer.
Regards,
Ankaiah Bandi
All Answers
Can you please try with below code.
If this helps, please mark it as best answer.
Regards,
Ankaiah Bandi