
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-02-2019 12:53 AM
There is a requirement to make the "comments" mandatory if someone rejects the Change Ticket via the list context menu UI Action i.e. right click on the Approver related list. I managed to make some modifications in the script posted in the community by someone else with similar requirement but its not working as expected. Although, after clicking Reject, its redirecting to enter the mandatory comments but after entering the comments, state is not changing to "Rejected". Can anyone help on this ?
function rejectRequest()
{
if (g_form.getValue('comments') == '')
{
//Remove any existing field message, set comments mandatory, and show a new field message
try {g_form.hideFieldMsg('comments');} catch(e) {}
g_form.showFieldMsg('comments','Please provide comments for rejection.','error');
return false; //Abort submission
}
//Call the UI Action and skip the 'onclick' function
gsftSubmit(null, g_form.getFormElement(),'Reject'); //MUST call the 'Action name' set in this UI Action
}
if (typeof window == 'undefined')
serverReject();
function serverReject()
{
current.state='rejected';
current.update();
}
Note : function rejectRequest(); is in 'Onclick' field of the ui action form.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-02-2019 02:19 AM
I use this as a ui action on the approval table with appropriate conditions
current.state = 'rejected';
if (!gs.nil(current.comments))
current.update();
else {
gs.addErrorMessage(gs.getMessage("Comments are required when rejecting an approval"));
current.state = 'requested';
current.setAbortAction(true);
action.setRedirectURL(current);
}
Bear in mind what you want your state to be if they don't add the comment.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-02-2019 04:12 AM
Just write a business rule that writes the comments from the approval to the comments on the change request
something like
When: before
Update: checked
Condition: current.comments.changes() && (!current.sysapproval.isNil()) && current.sysapproval.sys_class_name == 'change_request'
Script:
var gr = new GlideRecord('change_request');
gr.get(current.sysapproval);
gr.comments = current.comments;
gr.update();
This only runs for change_requests
In your ui action add the condition
current.sysapproval.sys_class_name == 'change_request'
So it stops you rejecting the approval until there is a comment. When you add the comment it allows reject and copies the comment to the change record

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2019 02:18 AM
Thanks Scott. Let me try my luck with this.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-07-2019 11:36 PM
Hi Scott,
I was able to achieve the same to much extent. Thanks for your help. I am now stuck at one major issue where I could see both the UI Actions in multiple classes. Even I have mentioned the conditions but the above UI Action is still visible on Knowledge Base related Approvals, RITM's etc. Is there any way to limit the visibility of the UI Action to only change_requests table ? Please see attached screenshot of both the UI Actions in List Context Menu. The first one is OOB which is there in for tables like KB, RITM (Request Items) etc.and the second one is what i created for Change_Request mentioning the condition. Only my one should show in Change Request and the other one should show in rest of tables as per the requirement.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-08-2019 04:48 AM
Hi
Your condition looks like it has too many and's or's etc
Try the following:
So for your Reject UI action (not seen in change)
current.state =='requested'&&(gs.hasRole('approval_admin') || gs.hasRole('admin') || isApprovalMine(current)&&(current.sysapproval.sys_class_name !='x_fii_mon_srm_new_mon_request') || !current.source_table.startsWith('change_request'))
And for your Reject Change Ticket action
current.state =='requested'&¤t.source_table.startsWith('change_request')
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2021 10:19 PM
Hi
What are the conditions for above UI action?