How to make comments mandatory when user click on Approve And reject button
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2023 04:46 AM
Hi All,
I have requirement how to make comments mandatory when user click on Approve And reject button
Approve script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2023 04:49 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2023 04:52 AM
Hi Mohith ,
I have written UI Action .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2023 04:58 AM - edited 08-11-2023 05:01 AM
@suresh40 you can modify the script to below
var currentRec = current.sys_id;
var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('sysapproval',currentRec);
gr.addQuery('state', 'requested');
gr.query();
while (gr.next()) {
if(!current.comments.isNil())
{
gr.state = 'approved';
gr.update();
}
else{
gs.addErrormessage("Comments are mandatory");
current.setAbortAction(true);
}
}
OR
what you can do is you can enable this Ui action on client side too by checking client check box and write one client code in the on click function to set the comments field mandatory and then use gfst submit to run the server code
some thing like this
function executeClient(){
if(g_form.getValue('comments')=="")
{
g_form.setMandatory('comments', true);
gsftSubmit(null, g_form.getFormElement(), 'approve'); // replace approve with yor button action name
}
}
if(typeof window == 'undefined'){
executeServer();
}
function executeServer(){
//your server side script
}
Hope this helps
Mark my answer correct if this helps you
Thanks