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

Getting started with Apex Trigger challenge Issue
Need help?
Challenge Not yet complete... here's what's wrong:
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_INSERT_UPDATE_ACTIVATE_ENTITY, AddRelatedRecord: execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Discount_percent__c]: [Discount_percent__c] Trigger.AddRelatedRecord: line 14, column 1: []
trigger AccountAddressTrigger on Account (before insert,before update) {
for(Account a :Trigger.new)
{
if(a.Match_Billing_Address__c == true)
{
a.ShippingPostalcode = a.BillingPostalcode;
}
}
}
Challenge Not yet complete... here's what's wrong:
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_INSERT_UPDATE_ACTIVATE_ENTITY, AddRelatedRecord: execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Discount_percent__c]: [Discount_percent__c] Trigger.AddRelatedRecord: line 14, column 1: []
trigger AccountAddressTrigger on Account (before insert,before update) {
for(Account a :Trigger.new)
{
if(a.Match_Billing_Address__c == true)
{
a.ShippingPostalcode = a.BillingPostalcode;
}
}
}
Please deactivate that trigger or Edit "Discount_percent__c" field and remove required checkbox.
And update your code like below
Let us know if this will help you
All Answers
You have missed the required field value assignment for "Discount_percent__c"
i have added some dummy value for this in your code. kinldy modify that using correct value.
use below updated code.
Hope this will help you.
Thanks
karthik
Please deactivate that trigger or Edit "Discount_percent__c" field and remove required checkbox.
And update your code like below
Let us know if this will help you
my very first code was this one where I used the __c. Why is it wrong? is it wrong using __c? thank you
The error I was getting is that the Trigger was not updating the Shipping post code.
GC
It should be a.Match_Billing_Address__c == true
I want to insert new Opportunity and with that insertion I want to create an OpportunityContactRoles , but can't achieve it.
Please help me in this!!
Here is my code.
What thing I should Implement to achieve the target.
trigger oppowithOCR on Opportunity (after insert) {
List<OpportunityContactRole> ocr = new List<OpportunityContactRole>();
List<Contact> con = [Select Id,Name from Contact];
For(Opportunity opp : trigger.new){
OpportunityContactRole oo = new OpportunityContactRole();
// oo.Id = opp.ContactId;
oo.OpportunityId = opp.Id;
oo.IsPrimary = true;
ocr.add(oo);
}
insert ocr;
}
Regards,
DMG