You need to sign in to do that
Don't have an account?
Vinay Salve
Bulk Apex Triggers - Account ID field missing error
Hello All,
Request you to pleaes kindly assist me in the Bulk Apex Trigger Trailhead, I have tried the following coding, however no luck in clearing the Trailhead as I get the error message stating - AccountID field missing.
trigger ClosedOpportunityTrigger on Opportunity (after insert) {
List<Task> taskListToInsert = new List<Task>();
for (Opportunity Opp:Trigger.new)
{
if (opp.StageName == 'Closed Won')
{
Task t = new Task();
t.Subject = 'Follow Up Test Task';
t.WhatID = opp.Id;
taskListToInsert.add(t);
}
}
if(taskListToInsert.size() > 0)
{
insert taskListToInsert;
}
}
Thanks
VInay Kumar Salve
Request you to pleaes kindly assist me in the Bulk Apex Trigger Trailhead, I have tried the following coding, however no luck in clearing the Trailhead as I get the error message stating - AccountID field missing.
trigger ClosedOpportunityTrigger on Opportunity (after insert) {
List<Task> taskListToInsert = new List<Task>();
for (Opportunity Opp:Trigger.new)
{
if (opp.StageName == 'Closed Won')
{
Task t = new Task();
t.Subject = 'Follow Up Test Task';
t.WhatID = opp.Id;
taskListToInsert.add(t);
}
}
if(taskListToInsert.size() > 0)
{
insert taskListToInsert;
}
}
Thanks
VInay Kumar Salve
All Answers
So what i am thinking here is the error is coming from some other trigger or process builder ..
Check the debug logs when you verify the challenge
Deactivate all other triggers and process builder and see
Thanks for responding, however I am not able to understand the problem witht the code, now I have a new error which is a s follows, request you to please assist, thanks
There was an unexpected error in your org which is preventing this assessment check from completing: System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_EXECUTE_FLOW_TRIGGER, We can't save this record because the “Opportunity Management” process failed. Give your Salesforce admin these details. This error occurred when the flow tried to create records: REQUIRED_FIELD_MISSING: Required fields are missing: [AccountId]. You can look up ExceptionCode values in the SOAP API Developer Guide. Error ID: 1566532941-39676 (1095682150): []
Thanks in advance.
Vinay Kumar Salve
and verify the challenge ..