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
Swathi CseSwathi Cse 

Update

the 'upsert' is creating duplicates Ordernumber,orderreleasenumber,productcode. how can I make just an update? if the ordernumber,orderreleasenumber,productcode is already there.

let me explain you, there two objects parent(Order Headers) and chld(DCR Orders), in order to create the Ordernumber I need to provide id and orderreleasenumber. All this is handle by the code. At this point if there is a pod with this fields for example Ordernumber=123, orderreleasenumber=0001, productcode=4 and I make another upsert to the same Ordernumber, i want the system to identify if there is a Ordernumber,orderreleasenumber,productcode with the same id(productcode is a master-detail)if that us true i want to update the productcode else insert new productcode thank you in advance!
James LoghryJames Loghry
Upserts are usually best with external id fields.  If you haven't already, you'll want to consider using an external id field on the product code (that is perhaps a combination of the order release number and order number).  Then using Apex, or the Soap API or whatever you're creating the product codes with, you'll specify the external id field in your upsert operation.  For instance here is an Apex snippet (notice how I'm specifying the external id field rather than letting it use the default Id field in the upsert operation):
 
Product_Code__c pc = new Product_Code__c(
    External_Id__c = 'OrderNumber=123,OrderReleaseNumber=001,ProductCode=4'
    ,Order__r = new Order__c(External_Id__c = '123')
    ,Order_Release__r = new Order_Release__c(External_Id__c = '001')
);
upsert pc External_Id__c;

For more info on upserts and external ids, please see: https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_upsert.htm