Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Restart workflow from UI action?

Edwin Fuller
Tera Guru

I have a UI action that reopens the record from a close state to an active state and sets the status back to in progress. I would also like to restart the workflow, can someone show me how that would be written?

Workflow Name = ConnectUs

Workflow sys_id = 17f8a0e46f452a00b2a0674f8e3ee4a7

UI Action Script

function worknotess(){

    if (g_form.getValue('work_notes') == '') {

          try {g_form.hideFieldMsg('work_notes');} catch(e) {}

          g_form.setMandatory('work_notes', true);

          g_form.showFieldMsg('work_notes','Work Notes are required');

    }

    gsftSubmit(null, g_form.getFormElement(), 'check_worknotes'); //MUST call the 'Action name' set in this UI Action

}

if (typeof window == 'undefined')

    serverResolve();

function serverResolve(){

    current.current_status = ('In Progress');

    current.actual_completion_date = '';

    current.update();

    }

1 ACCEPTED SOLUTION

Replace line new Workflow().restartWorkflow(current, true);


with new global.Workflow().restartWorkflow(current, true);


View solution in original post

8 REPLIES 8

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hello Edwin,



Place the below line above current.current_status = 'In Progress';



new Workflow().restartWorkflow(current, true);


I receive the following error below when adding the line below above current.current_status = 'In Progress';



new Workflow().restartWorkflow(current, true);



find_real_file.png


Replace line new Workflow().restartWorkflow(current, true);


with new global.Workflow().restartWorkflow(current, true);


Perfect - That worked exactly how I wanted it to, thank you!!