You need to sign in to do that
Don't have an account?
SFDC16
WhatId error
Below are trigger and error.
Error: Compile Error: Variable does not exist: whatId at line 13 column 14
trigger LinkdTaskToIncident on BMCServiceDesk__Incident__c (before insert)
{
List<BMCServiceDesk__Task__c> task=new List<BMCServiceDesk__Task__c>();
for(BMCServiceDesk__Incident__c c:Trigger.new)
{
if(c.BMCServiceDesk__Is_New_Record__c==true)
{
BMCServiceDesk__Task__c t = new BMCServiceDesk__Task__c();
t.BMCServiceDesk__taskDescription__c=c.BMCServiceDesk__incidentDescription__c;
whatId=c.id;
task.add(t);
}
}
insert task;
}
Error: Compile Error: Variable does not exist: whatId at line 13 column 14
trigger LinkdTaskToIncident on BMCServiceDesk__Incident__c (before insert)
{
List<BMCServiceDesk__Task__c> task=new List<BMCServiceDesk__Task__c>();
for(BMCServiceDesk__Incident__c c:Trigger.new)
{
if(c.BMCServiceDesk__Is_New_Record__c==true)
{
BMCServiceDesk__Task__c t = new BMCServiceDesk__Task__c();
t.BMCServiceDesk__taskDescription__c=c.BMCServiceDesk__incidentDescription__c;
whatId=c.id;
task.add(t);
}
}
insert task;
}
In the code of your custom trigger you are initiatiing your custom object after the if condition and then on line no. 13 you are assigning the value to WhatId which is not the field of your custom object...In short you are trying to write trigger on Custom object and using one of the fields of task object which is not correct.
WhatId is the field of Task and not your custom object.
Waiting for your response if this might solve your issue.
All Answers
Just update your line no. 13 of code from whatId = c.id ------------ t.whatId = c.id...
The notation is missing everything else is fine.
Also, please Mark it as the best answer.
In the code of your custom trigger you are initiatiing your custom object after the if condition and then on line no. 13 you are assigning the value to WhatId which is not the field of your custom object...In short you are trying to write trigger on Custom object and using one of the fields of task object which is not correct.
WhatId is the field of Task and not your custom object.
Waiting for your response if this might solve your issue.