0

On CPQ quote object When we click on submit for approval button, status is changed to In review, when the status is changed to in review. I Have to populate a field from quote associated quotelineitems product.

When I tired to do by using After update I m not getting the status value as In Review in debug logs

I am getting this error System.FinalException: Record is read-only

How Do i capture the status as inreview after approval process and update.

1

You need to use a "before update" trigger instead. As the error implies, you cannot change the status (or any other value) of a record in an after trigger, as the data is already committed to the database. You will still be able to see the new values in a "before update" trigger, but those changes can be altered before being committed.

  • When I use before update status value is still Draft, not In Review. So, my logic is not firing – teeshu Jul 25 at 18:52
  • 1
    You'll need to read your debug logs and/or write some unit tests to discover why. It's not immediately obvious in your code where the mistake is. Or, alternatively, you may have another trigger or process that's changing the status afterwards. This is one of those times where you'll likely need to learn about debugging to figure out a solution. – sfdcfox Jul 25 at 18:55
  • Thanks i figured out there was workflow rule causing issue. Before update is working – teeshu Jul 25 at 21:05
  • In the Last block of code I am checking condition for quote type and quote contract end date. Although the contract has end date it gives null and not entering the loop. What am I doing wrong. – teeshu Jul 25 at 21:10
  • @teeshu I'm not sure I follow. Usually it's because you're looking at the wrong record. Relationship fields are not automatically populated.. Make sure you're querying the data you need and using a map. – sfdcfox Jul 25 at 22:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.