
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-15-2017 08:02 AM
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();
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-15-2017 08:12 AM
Replace line new Workflow().restartWorkflow(current, true);
with new global.Workflow().restartWorkflow(current, true);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-15-2017 08:16 AM
You are very welcome Edwin. Thanks for participating in the community!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-01-2018 04:39 AM
Good Morning,
This doesn't seem to work on the London release, I have a UI Action on the sc_task table and want the Workflow to restart to adjust for the new Hardware Loan Date, I have most of it working except for the workflow restart:
I thought maybe as its in the sc_task table I would need to use a GlideRecord to go up a level to the req_item Table and restart the workflow from there...
Script:
var date = current.request_item.request.u_return_date;
var workflow_restarted = 'Yes';
var gdt = date.getGlideObject();
gdt.addDays(7);
var gr = new GlideRecord('sc_request');
gr.addQuery('sys_id', current.request_item.request);
gr.query();
if(gr.next()) {
gr.setValue('u_return_date', gdt);
gr.update();
}
var gr_sc_item = new GlideRecord('sc_req_item');
gr_sc_item.addQuery('sys_id', current.request_item);
gr_sc_item.query();
if(gr_sc_item.next()) {
new global.Workflow().restartWorkflow(current, true);
gs.log('Workflow restarted....');
}
Any suggestions I would be grateful for.
Kind Regards
Ashley

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-15-2017 08:05 AM
We use the following script to restart a workflow for a service request.
new WorkflowApprovalUtils().reset(current, "Restarting the workflow");
current.state = "requested";
current.u_last_approved_by = "None";
current.request_state = "requested";
current.update();
Please mark this response as correct or helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-15-2017 08:12 AM
This is different from a service request and uses a custom workflow