function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Li LeeLi Lee 

Sales Agreement Product Schedules

We use Salesforce Manufacturing Cloud for our business. We create a VF page show SalesAgreementProductSchedule record and edit those records.
To get and update records, we use JavaScript Remoting.During test, we found follow weird behavior in Salesfoce.
If we send SalesAgreementProductSchedule like { PlannedQuantity: 48, ID: 0YC8b0000008SDiGAM }, Salesforce Database.update throw error and we can not update this record. But if we put ID at first field in record like { ID: 0YC8b0000008SDiGAM, PlannedQuantity: 48 } we can success update this record.
I want to ask you why cause this behavior? Is there any document about it?
Best Answer chosen by Li Lee
Li LeeLi Lee
Hi, after we research more document we found solution in Salesforce Document: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_Schema_SObjectType.htm

In this document has follow content:

User-added image
So we change our code as follow:
if (hasId) {
    newSObject(id);
} else { 
    newSObject();
}

All Answers

SwethaSwetha (Salesforce Developers) 
HI Li,
I checked the related documentation https://developer.salesforce.com/docs/atlas.en-us.234.0.mfg_api_devguide.meta/mfg_api_devguide/sforce_api_objects_salesagreementproductschedule.htm but do not see anything about order of parameters.

What is the complete error message thrown? Can you share more details on how to reproduce this behavior so I can test in my org to suggest better?

Thanks
Li LeeLi Lee
Hi, after we research more document we found solution in Salesforce Document: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_Schema_SObjectType.htm

In this document has follow content:

User-added image
So we change our code as follow:
if (hasId) {
    newSObject(id);
} else { 
    newSObject();
}
This was selected as the best answer