Skip to main content
Hitesh Chaudhari a posé une question dans #Desktop Integration
I am getting follwing error when trying to create a new task and link it to incident.

 

"mytask13: execution of BeforeUpdatecaused by: System.NullPointerException: Attempt to de-reference a null object()"

 

I am trying update incident who hasn't assigned any template and attached to task.

 

Those incident who satisfy above condition I want their task's description to be updated and respected incident's template need to update.   

 

Following is the code I am using :  

 

trigger mytask13 on BMCServiceDesk__Task__c(after update,before update)

 

{

 

        List<BMCServiceDesk__Incident__c> myinc{get;set;}

 

        

 

    for(BMCServiceDesk__Task__c myobject :Trigger.new)

 

    {

 

      List<BMCServiceDesk__Task__c> mytask = [SELECT id,name,BMCServiceDesk__FKIncident__c FROM BMCServiceDesk__task__c where BMCServiceDesk__FKIncident__c !='' and BMCServiceDesk__FKIncident__r.BMCServiceDesk__FKTemplate__c = ''];

 

               myobject.BMCServiceDesk__taskDescription__c = 'task description updated through trigger';

 

               myobject.BMCServiceDesk__FKIncident__r.BMCServiceDesk__FKTemplate__c= 'a3k7F0000004UNvQAM';

 

               

 

           

 

    }

 

}
2 réponses
  1. 15 janv. 2018, 15:05
    BMCServiceDesk__FKIncident__c !='' : it gives us list of task who are attached to incident 

     

    and 

     

    BMCServiceDesk__FKIncident__r.BMCServiceDesk__FKTemplate__c = ''  : it gives me list of incident who dosnt assigend any template.

     

    As I need to check both the conditions I put them inside the query . i.e incident whose template field is blank and it is attached to an task as well. 
0/9000