+ Start a Discussion
Mauricio OliveiraMauricio Oliveira 

Can't reproduce UI behavior on test: update on quotelineitem updates quote too

Hi there,

I have the following situation:
- My Quote has a field that is updated on its afterUpdate trigger, based on a calculation involving its QuoteLineItems
- If I simply update one of the QuoteLineItems via UI (edit item, change value, save), it also does an update on the Quote, firing its triggers which ends up calculating the value of the field I mentioned above, works fine.
- However, If I just make an 'update item' on my test, it does not update the Quote, which ends up not calculating the mentioned field

I can't see a reason why the Quote is also being updated through the UI. So, before going deeper in debug logs, I'm just wandering if there is something very obvious that I might be missing. Any thoughts?

Thanks.
 
Best Answer chosen by Mauricio Oliveira
YuchenYuchen
That seems to be standard Salesforce behavior. I did a quick test in my org, for my org, there is no roll up summary or any custom code/settings on Quote and QuoteLineItem. When I just go to Quote Line Item and update the quantity, after I save the QuoteLineItem, I found out the last modified date for the Quote got updated to the current time as well. So I am thinking Salesforce is doing something internally to update the Quote when the QuoteLineItem is touched.

All Answers

Varun PareekVarun Pareek
Mauricio - Do you have any roll up summary fields on "Quote". If yes, you may want to check if updating the "quotelineitems" is affecting this roll up summary field (if it is criteria based). If this is true, this might be the reason for the trigger to fire.
YuchenYuchen
That seems to be standard Salesforce behavior. I did a quick test in my org, for my org, there is no roll up summary or any custom code/settings on Quote and QuoteLineItem. When I just go to Quote Line Item and update the quantity, after I save the QuoteLineItem, I found out the last modified date for the Quote got updated to the current time as well. So I am thinking Salesforce is doing something internally to update the Quote when the QuoteLineItem is touched.
This was selected as the best answer
Varun PareekVarun Pareek
Agreed. Quotes are OOTB salesforce. You may not have explicilty defined any roll up summary fields, but internally the quote may be getting updated.
Mauricio OliveiraMauricio Oliveira
Thank you both for the reply.

I was suspecting that this was a standard Salesforce behavior, but I couldn't find this documented anywhere. My concern is to be able to reproduce in tests the exact behavior of UI changes. I guess I will just add an 'update quote' to my tests right now, but it would be really nice to be sure that we are correct assuming that is expected behavior to update even if without roll-up summary fields.

Thanks again.