Why is a Quote line logic called twice when I add a new line?

Question

When you have a Quote and add a new line item, either via a button in the user interface or via a Quote header calculation logic, the Quote line logic is executed twice. The first time with api.currentItem() returning null and the second time with api.currentItem() returning the whole line. Why is that so?

Answer

The reason is that the system needs to evaluate the inputs created for the line. So the system calls the Quote line logic twice:

  1. To evaluate the inputs needed on the line.

  2. To evaluate all the results.

Found an issue in documentation? Write to us.