Troubleshooting: Custom onRender Causing Error on Sheet Save
Issue:
User created a new Sample Protocol with an onRender and added it to the end of each of the main workflows
When completing and saving the worksheet and clicking Submit to Next Workflow, an error appears indicating the worksheet needs to be saved first
User does not see errors in the network and console tabs using Dev tools
Solution:
This issue is likely that it's due to the JS invokable in the onRender
This will typically occur when the user sets cell data using the onRender
Note that each time a page refreshes, the onRender fires off
This includes simply clicking ‘Save’ and as a result the data in the worksheets gets entered into the database and then the page refreshes
During the page refresh, the onRender triggers again and now the worksheet is left in a ‘Dirty’ state resulting in an error stating that the worksheet needs to be saved again
A user wouldn't notice this when using Save and Continue to the next protocol in a workflow, or perhaps ignore the popup that mentions unsaved data when continuing to the next protocol
However, when an onRender like this is the final protocol in a workflow that's going to transition to a subsequent workflow, the users will get the error
One resolution would be to check what's in those cells before they are set, and if it's the same value as what the user is planning to set it to, do not set it
A second option would be to switch the strategy and use an expression instead of customer onRender in the final protocol of the workflow