0

Error on inserting Child record on custom object which is having Master Detail relationship with other Custom Object.

I have two custom Objects x and Y which are in Master Details Relations. There is on field on Custom Object Y say (z) which having Master detail Relation ship with x.

when I am inserting Y record without filling the 'z' field system throwing an error "System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing"

When i give z=x.id and do insert, its throwing an error saying "Field does not exist"...

Let me know how can i fix it.

  • 1
    You should be doing something like y.Z__c = z.Id;. – Keith C Sep 18 '19 at 21:03
  • I didn't get you and the details provided above are related to Managed Package. I mean the custom objects are related to Managed Package – Venkat V Sep 19 '19 at 13:23
  • If your code is inside the managed package, field names will be e.g. Abc__c. If your code is outside the managed package, field names will be XXX__Abce__c when XXXsdhould be replaced with the managed package namespace. – Keith C Sep 19 '19 at 13:43
  • Though i am giving the field name correctly it's system saying it doesn't exist while inserting the record. I queried this field in Query editor to see records and it was showing up with the name as i mentioned. If i don't consider that field system throwing an error saying required fields is missing.But when i am saving this record in UI i am not encountering with any issues, record successfully saving. – Venkat V Sep 19 '19 at 14:20
  • One thing i noticed under the Setup-->Installed Package-->View Components-->Unused Components-->field showing with View Components section of Installed Package under the Package Information as "Available in Versions 1.42 - 1.43 (Deprecated)". So i am thinking because it's deprecated it cannot be used. – Venkat V Sep 19 '19 at 14:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.