- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2024 09:23 AM
Hi,
I created two UI Action cancel buttons for both a parent form and child task. I needed them both for the submitter and reviewer to cancel at anytime. Neither are working.
I have taken screenshots of the parent & child task cancel buttons.
Here is the parent cancel button script.
current.setValue("state", "107");
current.comments = "[code]<b>Request Cancelled</b>[/code] by " + gs.getUserDisplayName();
current.update();
var flowGR = new GlideRecord('sys_flow_context');
flowGR.addQuery('source_record', current.sys_id);
flowGR.query();
flowGR.next();
sn_fd.FlowAPI.cancel(flowGR.getValue('sys_id'), 'Cancelled by submitter');
Child task cancel button script.
current.setValue("state", "7");
current.comments = "[code]<b>Request Cancelled</b>[/code] by " + gs.getUserDisplayName();
current.update();
var flowGR = new GlideRecord('sys_flow_context');
flowGR.addQuery('source_record', current.sys_id);
flowGR.query();
flowGR.next();
sn_fd.FlowAPI.cancel(flowGR.getValue('sys_id'), 'Cancelled by submitter');
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2024 09:59 AM
@Andre241 You have checked the client checkbox on both the UI Actions and defined a cancelRequest() function call inside onClick field. Do you have this cancelRequest() function defined some where inside your script field?If yes then does this function do something on the client side?
Since the script you shared is the server side script, I recommend emptying the onClick field and unchecking the client checkbox. This should let the script execute on the server side.
Also, if this doesn't resolve your issue, try adding gs.info(''); logs. in your script and see at which line the script breaks.
Hope this helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2024 09:59 AM
@Andre241 You have checked the client checkbox on both the UI Actions and defined a cancelRequest() function call inside onClick field. Do you have this cancelRequest() function defined some where inside your script field?If yes then does this function do something on the client side?
Since the script you shared is the server side script, I recommend emptying the onClick field and unchecking the client checkbox. This should let the script execute on the server side.
Also, if this doesn't resolve your issue, try adding gs.info(''); logs. in your script and see at which line the script breaks.
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2024 09:33 AM
Thank you. It worked.