You need to sign in to do that
Don't have an account?
Maxim Petrosov
System.DmlException Problem
trigger ClosedOpportunityTrigger on Opportunity (after insert) {
List<Task> taskListToInsert = new List<Task>();
for(Opportunity opp:Trigger.new)
{
if(opp.StageName == 'CloseWon')
{
Task t = new Task();
t.Subject = 'Follow Up Test task';
t.WhatId = opp.Id;
taskListToInsert.add(t);
}
}
if(taskListToInsert.size() > 0)
{
insert taskListToInsert;
}
}
When I'm trying ti invoke this trigger I have this error
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: REQUIRED_FIELD_MISSING, Required fields are missing: [Discount_Percent__c]: [Discount_Percent__c]
Can anyone help me with this?
List<Task> taskListToInsert = new List<Task>();
for(Opportunity opp:Trigger.new)
{
if(opp.StageName == 'CloseWon')
{
Task t = new Task();
t.Subject = 'Follow Up Test task';
t.WhatId = opp.Id;
taskListToInsert.add(t);
}
}
if(taskListToInsert.size() > 0)
{
insert taskListToInsert;
}
}
When I'm trying ti invoke this trigger I have this error
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: REQUIRED_FIELD_MISSING, Required fields are missing: [Discount_Percent__c]: [Discount_Percent__c]
Can anyone help me with this?
How are you invoking the trigger? Is it in an Apex test class that you're getting the error?
Thanks a lot that you found a time to reply. I created this trigger for Opportunities to complete my challenge.
When I'm checking it System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Discount_Percent__c]: [Discount_Percent__c]
But I have already this Discount_Percent__c field in Opportunity Custom Fields & Relationships. I don't know what I have to do.