Problem with rollup numbers when user updates both related record and parent record simultaneously

Mamta Sangwan
ServiceNow Employee
ServiceNow Employee

Issue: Value on record are getting overridden when 2 actions are simultaneously performed.
When a user updates a child record (such as a resource plan or cost plan that rolls up the total planned cost on the demand record) from the related list and immediately clicks the save button for the demand form, the values from the child record get updated to the demand record and are later overridden with the previous value.

For example, if the demand shows a total planned cost of $1000 and the user updates the child record (cost plan) to make the total planned cost $1500, the history of the demand record will show the value changing from $1000 to $1500 and then back to $1000.

How can we fix this issue?

4 REPLIES 4

Rajesh Chopade1
Mega Sage

Hi @Mamta Sangwan 

 

The issue you are describing suggests that there is a problem with how the planned cost is being calculated and updated on the parent record (the demand record) when a child record (the cost plan) is modified. This might be due to how the business rules or scripts are set up to handle these updates.

 

Check Business Rules and Scripts:

  • Identify any business rules, client scripts, or UI actions associated with the child record (cost plan) that might be updating the parent record (demand record).
  • Look for scripts that trigger when a cost plan is updated and ensure they correctly calculate and set the planned cost on the demand record.

Review Update Logic:

  • Ensure the logic that updates the planned cost on the demand record accurately sums up the costs from all related cost plan records.
  • Verify that the calculation logic doesn't inadvertently reset the planned cost back to its previous value.

Audit History Configuration:

  • Ensure that the audit history is correctly configured to track changes to the planned cost fields. This will help you understand the sequence of changes happening when a cost plan is updated.

 

i hope my answer helps you to resolve your issue if yes, mark my answer helpful and correct.

 

THANK YOU

rajesh chopade

Mamta Sangwan
ServiceNow Employee
ServiceNow Employee

Hi @Rajesh Chopade1 ,
Thanks for the response.
Business rules on cost plan are correctly set, it is updating the planned cost correctly on demand record. This issue comes only when user click on save action of demand record immediately after updating child record (cost plan). 
Audit history also shows this updates. Attached the screenshots.
On save of Demand record, we are doing current.update(). I am suspecting it is reverting the value, but not sure why only few values are getting overridden not all. 


Rajesh Chopade1
Mega Sage

Hi @Mamta Sangwan 

This might be due to timing and the order of operations in ServiceNow. Here are some steps to troubleshoot and potentially resolve the issue:

 

1) Verify BR execution order:

Ensure that the business rules on the cost plan and demand records are executing in the correct order. Specifically, ensure that:

  • The business rule that updates the demand record's planned cost based on the cost plan is set to run before the demand record is saved.
  • Any business rules on the demand record that might update the planned cost are not conflicting or overriding the changes.

2) Use 'current.update()' carefully:

Calling current.update() within a business rule can sometimes cause issues if it triggers additional business rules or workflows that might revert changes. Consider the following:

  • Ensure current.update() is necessary and doesn't inadvertently cause recursive updates or conflicting changes.
  • If current.update() is needed, make sure it’s called in a controlled manner to prevent unexpected results.

3) use flag to prevent recursive updates:

You can use a flag to prevent recursive updates. Set a scratchpad variable to indicate when the update is happening and use it to control the flow.

 

I hope my answer helps you to resolve your issue if yes, mark my answer helpful & correct.

THANK YOU

rajesh chopade

Mamta Sangwan
ServiceNow Employee
ServiceNow Employee

Hi @Rajesh Chopade1 ,
Thanks for the response!
We have Before BR which updates 'total planned cost' on Demand record. There is only one BR which updates this field.
current.update() is not used in the BR. It is present on the save button.
Screenshot 2024-08-01 at 4.18.24 PM.pnghistory.png