Need Cancel button on form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2024 07:49 PM
I need a cancel button on portal that changes the state to closed complete.
I have this from a widget that is active.
server script:
} else if (input.action == 'cancel') {
gr.setValue('state', 7);
gr.comments = "[code]<b>Request Cancelled</b>[/code] by " + gs.getUserDisplayName();
gr.update();
var flowGR = new GlideRecord('sys_flow_context');
flowGR.addQuery('source_record', data.sys_id);
flowGR.query();
flowGR.next();
sn_fd.FlowAPI.cancel(flowGR.getValue('sys_id'), 'Cancelled by submitter');
} else if (input.action == 'complete'){
if (gr.getTableName() == 'x_g_duas_abm_srrb')
gr.setValue('state', -17);
else
gr.setValue('state', 3);
gr.comments = "Review task completed by " + gs.getUserDisplayName();
gr.update();
}
}
Client Controller:
c.cancelAction = function() {
$rootScope.$broadcast("action.initiated");
c.server.get({
action: 'cancel'
}).then(function() {});
}
Here is the table "x_g_duas_abm_contract_action_review"
sys_ID contract_action_review
"cancelled state" = 107
Please any assistance would be great.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2024 08:01 PM - edited 05-14-2024 08:02 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2024 08:41 AM
Thanks, but the info you provided is for new cancel widget.
I need to edit an existing widget. Here is the info from the existing widget.
server script:
} else if (input.action == 'cancel') {
gr.setValue('state', 7);
gr.comments = "[code]<b>Request Cancelled</b>[/code] by " + gs.getUserDisplayName();
gr.update();
var flowGR = new GlideRecord('sys_flow_context');
flowGR.addQuery('source_record', data.sys_id);
flowGR.query();
flowGR.next();
sn_fd.FlowAPI.cancel(flowGR.getValue('sys_id'), 'Cancelled by submitter');
} else if (input.action == 'complete'){
if (gr.getTableName() == 'x_g_duas_abm_srrb')
gr.setValue('state', -17);
else
gr.setValue('state', 3);
gr.comments = "Review task completed by " + gs.getUserDisplayName();
gr.update();
}
}
Client Controller:
c.cancelAction = function() {
$rootScope.$broadcast("action.initiated");
c.server.get({
action: 'cancel'
}).then(function() {});
}
Here is the "Cancelled state" = 107, and it's pulling from this table
Here is the table "x_g_duas_abm_contract_action_review"
sys_ID contract_action_review