You need to sign in to do that
Don't have an account?
What are the implication for the "POST" rest call on child object when it's in mater detail relationship
Hi Devs,
I have 2 custom objects
1) order having fields -> orderId, pobox, emailaddress etc. some of these are required fields.
2) item refer to order in master detail relationship, order was created first so assuming that will be master.
item having fields -> itemid, category, orderId , Order__c
WHen I make post call on item without any fields of Order in payload it return exception saying "message": "Required fields are missing: [Order__c]"
My questions is do I need to pass all fields of "order" object when I do POST on item object or just those which are required once under order object field definition? Or Is there any other way to refence the order object while making post call to item object?
I am assuming that you are trying to insert "Item'' record in Salesforce which is a child of "Order" object. If that's the case then the request body for item should have the "Order" record Id in it since it is a master-detail relation.
For example : If the system has an order "O-001" with salesforce Id "XXXXX.." and you wish to insert item under this order then the paylod should be something similar to this :
{
"Category__c" : "XYZ", //If it is a picklist then any of the desired value to be passed.
"Order__c" : "XXXXX.." //The recordId of the order under which this item has to be inserted.
.....
}
Hi Syed,
Thanks but I am not clear on what would be record Id or salesforceid for "Order" object?
I haven't created any record type for the order or item custom objects as I didn't see the need of it.
It seems it is implied this problem can not be solved without creating record type ?
By the way, This is how specs looks like;
Order custom object:
value:
orderNo__c: "223z3a55b780" # required field
currencyCode__c: "USD"
subTotal__c: 41.5
email:__c "test0@test.com". #required field
Item custom object:
value:
id__c: "2280"
category__c: "snacks"
quantity__c: 3
orderId__c: "223z3a55b780"
order__c: "18 char alphanumeric " #say a0XXXXXXYZQAW
I tried with 18char SF id for order 223z3a55b780 but it still return the error;
"message": "Order: id value of incorrect type: a0XXXXXXYZQAW FIELD_INTEGRITY_EXCEPTION"
I am passing SF id of the record as json string seems like salesforce api is not liking it.
If you any Order record in Salesforce; go to the detail page of the record. The URL will have the id which is the record Id that needs to be passed while creating Item record in Salesforce.
For example: If I access Account record in Salesforce this is how the URL looks :
https:<Your_Domain>>.lightning.force.com/lightning/r/Account/001XXXXXXXXXX/view.
Record Id is 001XXXXXXXXXX.