Trigger workflow on record update

roshanrao
Kilo Expert

Hi All,

I have the need to update a business system every time a record is inserted or some of its fields updated.

The integration to this system is using SOAP-based web services - I am using a workflow because the SOAP call is async (MID) and it is easier to build out error handling with workflows.

My workflow is getting triggered properly when a record is inserted. It does not when the record is changed. What are my options to trigger it "after update".

1. I would prefer not to pull my logic into after or async business rules - primarily because I would have to build out components for exception handling.

2. Another option is to have the insert workflow go into a wait state and monitor for updates. Again, this is probably not the most efficient way of doing this, given that the automation lifetime in happy path does not have to be more than a few seconds. Long running workflows would have impacts on the system over a period.

Thoughts?

- Roshan

1 ACCEPTED SOLUTION

To close this out.


I ended up adding a field called "Last Committed Update" to my table(s). This is the equivalent of sys_mod_count and its value should be equal to sys_mod_count if the workflow completes. That way I can see records that have gone out of sync (pending workflow completion, or failed).


I was able to kick off workflows on update (restart) by adding a BR that did this:


restartWorkflow: function(current) {


new global.Workflow().restartWorkflow(current);


current.autoSysFields(false);


current.update();


}



I updated the workflow to be "post BR" and updated the triggering BR to have Order >=1000. This graphic is useful in understanding the execution order: https://docs.servicenow.com/bundle/istanbul-servicenow-platform/page/administer/using-workflows/conc...


The one other piece was that workflows had a limited # of restarts because there is a default limit on the number of activities (Max activity count in Workflow Properties). Since these workflows were technical in nature, I did not need to keep the history. So, I was able to get away adding a job to delete inactive workflows.



All in all, I felt like I was driving a square peg into a round hole. If I have to do this again, I will likely not use workflow for this purpose.


View solution in original post

6 REPLIES 6

Service Manager
Kilo Guru

Hi Roshan,

 

we are working on SOAP-based web services integration. Could tell me how the workflow is getting triggered on insert of record into table.?

 

Thanks

Hi - This thread is about triggering workflows on record updates. For insert, it is pretty simple. If the conditions on the workflow are met, the workflow will be triggered, and you can add whatever integration code you need in the workflow as activities.

 

- R