Want to create a monitoring workflow that restarts the workflows automatically in finished state | Community
Skip to main content
Level 2
June 12, 2023
Solved

Want to create a monitoring workflow that restarts the workflows automatically in finished state

  • June 12, 2023
  • 2 replies
  • 2602 views

Hi,

 

I want to create a workflow that picks up all the workflows in finished state and restart them automatically without manually doing it. Wanted to know if there is any way that the restart can be done through a monitoring workflow and without an API call?

 

Reason being, we have been observing workflows going to finished state without processing (Scheduled workflows or external signal). The root cause and fix is not known yet, so wanted to restart the workflow automatically to avoid any delays sending communications.

 

Thanks,

Maliha

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by jjwatson79

The issue with this approach is it does not actually start the workflow. I have run a test on a few instances, and all the happens is the logs show the workflow starting and finishing, with none of the activities carrying out any actions.

 

@isahoregave the JS method approach that would activate the workflow completely, rather than just changing the status.

 

I prefer a mixed approach. I would recommend building up the list of workflows using a query activity to simplify the approach. I would follow the query activity with a JS activity, containing the following code.

//Query the schema to extract the XML from eventData var query = xtk.queryDef.create( <queryDef schema={vars.targetSchema} operation="select" lineCount={vars.recCount}> <select> <node expr="@id"/> </select> </queryDef> ) var workflowsToStart = query.ExecuteQuery(); for (i=0; i < vars.recCount; i++ ) { xtk.workflow.Start(workflowsToStart[i].@id); }

 

This approach allows for a less technical user to configure the logic using a query activity, and execute the backend method that will actually start the workflow. @isahore , you are correct that this requires the workflow to run in order to execute, but it seems a reasonable trade-off to me.

2 replies

LakshmiPravallika
Community Advisor
Community Advisor
June 12, 2023

Hi @maliha27 ,

 

Yes you can create a workflow which makes the state to "Started" for all the workflows which went to "Finished" State as per your requirements.

 

There is a schema called "xtk:workflow" OOTB Schema where you can update the particular workflows state what ever you want by doing a query a

nd then Update Data.

 

Example:

 

In the First query activity, please take the base schema as "xtk:workflow" and then select the Internal names of workflows as per your requirement and the state is equal to Finished for them.

In the Update Data activity, Please updates those status to "Started" as below:

 

you can manually do this process as shown above instead of doing for each and every workflow.

 

Regards,

Pravallika.

 

 

 

jjwatson79
jjwatson79Accepted solution
Level 2
June 12, 2023

The issue with this approach is it does not actually start the workflow. I have run a test on a few instances, and all the happens is the logs show the workflow starting and finishing, with none of the activities carrying out any actions.

 

@isahoregave the JS method approach that would activate the workflow completely, rather than just changing the status.

 

I prefer a mixed approach. I would recommend building up the list of workflows using a query activity to simplify the approach. I would follow the query activity with a JS activity, containing the following code.

//Query the schema to extract the XML from eventData var query = xtk.queryDef.create( <queryDef schema={vars.targetSchema} operation="select" lineCount={vars.recCount}> <select> <node expr="@id"/> </select> </queryDef> ) var workflowsToStart = query.ExecuteQuery(); for (i=0; i < vars.recCount; i++ ) { xtk.workflow.Start(workflowsToStart[i].@id); }

 

This approach allows for a less technical user to configure the logic using a query activity, and execute the backend method that will actually start the workflow. @isahore , you are correct that this requires the workflow to run in order to execute, but it seems a reasonable trade-off to me.

ParthaSarathy
Community Advisor
Community Advisor
June 12, 2023

Hi @maliha27 and @jjwatson79 ,

As you want to restart your workflow, Instead of using xtk.workflow.Start, you can try using xtk.workflow.Restart

 

Start > Start or Resumes execution of a workflow

Whereas, Restart > Links together a workflow stop and a workflow start from beginning.

Solution:

Workflow should be like, 

 

Query:

Targeting dimension: xtk:workflow

Filtering dimension: xtk:workflow

 

Make sure not to give all workflow name in your instance. So you can give the selected Workflows internal name here, which you founds to be restarted.

 

Javascript&colon;

 

var query = xtk.queryDef.create( <queryDef schema="temp:query" operation="select"> <select> <node expr="@id"/> </select> </queryDef> ); var record = query.ExecuteQuery(); for each (var variable in record) { vars.workflowID = variable.@id; xtk.workflow.Restart(vars.workflowID); }

 

 

Now When I ran the above workflow, I can see all the 3 workflows mentioned in Query activity have restarted in my environment.

 

But as part of BEST PRACTICEKeep this solution as a temporary solution and try to figure it out why the workflows are going to finished state without processing and fix the issue. 

~  ParthaSarathy S~  Click here to join ADOBE CAMPAIGN USER GROUP for Quarterly In-person | Hybrid | Virtual Meetups