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
DrebinDrebin 

Jsforce Upsert QuoteLine object

HI there,

I try with a custom script to upsert a QuoteLineItem but I face a problem with the SBQQ__Quote__c field, which is a Master-Detail of the Quote object.

This is my code :
export function onBeforeCalculate(quoteModel, quoteLineModels, conn) {
  console.log('ytjtuio');
  console.log(quoteModel);
  console.log(quoteLineModels.length);
  console.log(quoteLineModels);
  
  
if(quoteLineModels.length >= 0)
{
  for( var i = 0; i < quoteLineModels.length; i++) {
   var quoteline = conn.sobject("SBQQ__QuoteLine__c").upsert({
           SBQQ__Product__c : quoteLineModels[i]._unproxiedModel.record.SBQQ__Product__c,
           SBQQ__OriginalQuoteLineId__c : quoteLineModels[i]._unproxiedModel.record.SBQQ__Quote__c,
           SBQQ__Quote__c : quoteLineModels[i]._unproxiedModel.record.SBQQ__Quote__c
           }, 'SBQQ__OriginalQuoteLineId__c',
           function(err, rets) {
  if (err) { return console.error(err); }
      console.log("Upserted Successfully");
    }
  );
  }
}
  return Promise.resolve();
}
When I do a save of the LineItems, I have this error : "INVALID_FIELD: The value provided for foreign key reference SBQQ__Quote__r is not a nested SObject". I tried with "SBQQ__Quote__c" field and I have this error : "INVALID_FIELD_FOR_INSERT_UPDATE: Unable to create/update fields: SBQQ__Quote__c. Please check the security settings of this field and verify that it is read/write for your profile or permission set."

Thanks for your help !