2

SteelBrick automatically updates custom fields from the Quote Line to Opportunity Product (see URL at bottom) BUT it only seems to do so after the Quote Line is updated, and not after the initial creation. So I am trying to write a trigger that updates two custom fields on the Quote Line, Saves the record, and then an Edit and Save to kick off the update. Getting different errors when trying different approaches, recursion errors, and System.FinalException: Record is read-only ().

trigger UpdateContractDates on SBQQ__QuoteLine__c (before insert, after update) {
  for(SBQQ__QuoteLine__c editedQuoteLine : trigger.new) {
    editedQuoteLine.NetSuite_Start_Date__c = editedQuoteLine.SBQQ__StartDate__c;
    editedQuoteLine.NetSuite_End_Date__c = editedQuoteLine.SBQQ__EndDate__c;

 List<SBQQ__QuoteLine__c> UpdateQL =[select id from SBQQ__QuoteLine__c where id = :editedQuoteLine.id];


update UpdateQL;


  }
}

http://community.steelbrick.com/t5/Get-Started-Knowledge-Base/Q-A-Auto-Mapping/ta-p/939

2
  • 2
    your link presumes we have login access to steelbrick support portal
    – cropredy
    May 7, 2016 at 17:54
  • 2
    I'd recommend you talk to SteelBrick support before you go off and write a trigger like this. You may be doing something that could be undermining your entire CPQ configuration that you've paid a lot of money for that you really don't want to do.
    – crmprogdev
    May 7, 2016 at 18:53

2 Answers 2

3

SteelBrick does upsert/delete oppty products upon initial save if the quote is marked primary, and if you're doing so from the line editor view...if you are manually creating a quote line record the standard Salesforce way, perhaps not.

2

1.It is simply disaster.You have SOQL and DML both in loop.

2.You are updating the same object in before insert on which the trigger is.That is not required and is the reason of recursion.

3.Trigger.new in afterUpdate is readonly.You can not make changes in that.Even Trigger.newList can only be modified in before triggers.

If i only talk about before insert your trigger should be something like this:

    trigger UpdateContractDates on SBQQ__QuoteLine__c (before insert) {
      for(SBQQ__QuoteLine__c editedQuoteLine : trigger.new) {
        editedQuoteLine.NetSuite_Start_Date__c = editedQuoteLine.SBQQ__StartDate__c;
        editedQuoteLine.NetSuite_End_Date__c = editedQuoteLine.SBQQ__EndDate__c;
   }
}

I would say you should revisit the logic of problem and restate that because right now it is hard to understand from your code.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .