You need to sign in to do that
Don't have an account?
Heather Thompson
error message - System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Employee, Job]: [Employee, Job]: Trigger.CreatePlaced: line 11, column 1
The error message was for the following trigger:
trigger CreatePlaced on Submission__c (before update) {
for (Submission__C sub : Trigger.new) {
If (sub.stage__c == 'placed') {
Placement__c placed = new Placement__c ();
placed.name = sub.name;
sub.candidate__C = placed.employee__c;
sub.job__c = placed.job__c;
Insert placed;
}
}
}
trigger CreatePlaced on Submission__c (before update) {
for (Submission__C sub : Trigger.new) {
If (sub.stage__c == 'placed') {
Placement__c placed = new Placement__c ();
placed.name = sub.name;
sub.candidate__C = placed.employee__c;
sub.job__c = placed.job__c;
Insert placed;
}
}
}
Please refer below updated code:
If this solves your problem, kindly mark it as the best answer.
Thanks,
Vatsal
All Answers
The first thing in your code is not following best parctise. We never use DML in for loop.
placed is a new instance of Placement__c so how you can assign placed.employee__c; value to candidate field and same as job.
And according to your error msg when you inserting placed object then some required fields are not filled.
Follow best practices
https://developer.salesforce.com/page/Apex_Code_Best_Practices
Please refer below updated code:
If this solves your problem, kindly mark it as the best answer.
Thanks,
Vatsal