restart – DijitalTurk https://dijitalturk.com/veysel Dijital Paylaşımlar Fri, 08 Mar 2024 21:11:17 +0000 en-GB hourly 1 Cancel existing WorkFlow and start process with new workflow https://dijitalturk.com/veysel/cancel-existing-workflow-and-start-process-with-new-workflow/ https://dijitalturk.com/veysel/cancel-existing-workflow-and-start-process-with-new-workflow/#respond Thu, 27 Apr 2023 13:48:53 +0000 https://dijitalturk.com/veysel/?p=1954 The following code block can be used to cancel the current workflow and start the process with the newly prepared

The post Cancel existing WorkFlow and start process with new workflow appeared first on DijitalTurk.

]]>
The following code block can be used to cancel the current workflow and start the process with the newly prepared workflow.

//Fonksiyon parametreleri: Kaydın tablo adı(table name), Kaydın sys_id'si(record sys_id), wf_workflow tablosunda ki work flow'un sys_id si(workflow sys_id).
restartFlow('change_request','49ce936787fc5d54520e557bbbbb35e7', 'df3ea2701b8a2c508968a8217e4bcbf8');

function restartFlow(record_table,record_sys_id, wf_v_sys_id) {
    var gr = new GlideRecord(record_table);
    var q = 'sys_id=' + record_sys_id;
    gr.addEncodedQuery(q);
    gr.query();
    if (gr.next()) {
          var oldWorkflow = new Workflow();
        oldWorkflow.cancel(gr);
        var w = new Workflow();
        var context = w.startFlow(wf_v_sys_id, gr, gr.update());
    }
}

Alternative:

var gr = new GlideRecord('sc_req_item');
gr.get('2632f478472611d403587d01e36d430f');

 var workflow = new Workflow();
 workflow.cancel(gr);

var newWorkflow = new Workflow();
newWorkflow.startFlow(new Workflow().getWorkflowFromName('WF_NAME'), gr, '');

 

The post Cancel existing WorkFlow and start process with new workflow appeared first on DijitalTurk.

]]>
https://dijitalturk.com/veysel/cancel-existing-workflow-and-start-process-with-new-workflow/feed/ 0