You need to sign in to do that
Don't have an account?

REQUIRED_FIELD_MISSING - DurationInMinutes
Hi,
I'm trying to deploy a trigger and a test class, but I got an error:
Error:
System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, CriarEventoOp_visita_agendada: execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Campos obrigatórios ausentes: [DurationInMinutes]: [DurationInMinutes] Trigger.CriarEventoOp_visita_agendada: line 19, column 1: []
Stack Trace: Class.CriarEventoOp_visita_agendada_test.MyUnitTest: line 10, column 1
"DurationInMinutes" it is not a Opportunity field.
But it is a field in Event.
Why I got this?
I'm trying to deploy a trigger and a test class, but I got an error:
trigger CriarEventoOp_visita_agendada on Opportunity (after insert, after update) { List<Event> EventRe = new List<Event>(); for (Opportunity op : Trigger.new){ if (op.StageName == 'Visita Agendada' || op.StageName == 'Visita reagendada'){ EventRe.add (new Event( EndDateTime = op.data_da_visita__c, OwnerId = op.OwnerId, Respons_lvel__c = op.Respons_lvel__c, StartDateTime = op.data_da_visita__c, Subject = 'Visita', Whatid = op.id )); } } insert EventRe; }
@IsTest(SeeAllData=true) public class CriarEventoOp_visita_agendada_test { static testmethod void MyUnitTest(){ Opportunity op = new Opportunity(); op.Name = 'teste'; op.StageName = 'Visita Agendada'; op.CloseDate = date.today(); insert op; op.OwnerId = 'op.OwnerId'; op.Respons_lvel__c = 'op.Respons_lvel__c'; update op; Event ev = new Event(); ev.DurationInMinutes = 1; ev.EndDateTime = op.data_da_visita__c; ev.OwnerId = op.OwnerId; ev.Respons_lvel__c = op.Respons_lvel__c; ev.StartDateTime = op.data_da_visita__c; ev.Subject = 'Visita'; ev.Whatid = op.id; insert ev; } }
Error:
System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, CriarEventoOp_visita_agendada: execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Campos obrigatórios ausentes: [DurationInMinutes]: [DurationInMinutes] Trigger.CriarEventoOp_visita_agendada: line 19, column 1: []
Stack Trace: Class.CriarEventoOp_visita_agendada_test.MyUnitTest: line 10, column 1
"DurationInMinutes" it is not a Opportunity field.
But it is a field in Event.
Why I got this?
Best!
here try this. I have added DurationInMinutes as the last property.
Please mark the Question solved by selecting a best answer, if it resolves your issue.
Good luck :)