How to make worknotes mandatory using UI actions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-23-2023 06:06 AM
I want to add a code to the below code to make the worknotes mandatory whenever user clicks on re-evaluate it should show pop up like please enter worknotes.
var approvals = new GlideRecord('sysapproval_approver');
approvals.addQuery('sysapproval.number', current.number);
approvals.addQuery('state', 'requested');
approvals.setLimit(1);
approvals.query();
while (approvals.next()) {
approvals.setValue('state', 'rejected');
approvals['comments'].setJournalEntry("Rejected by " + gs.getUserDisplayName() + " for re-evaluation");
approvals.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-23-2023 06:13 AM
Hi @divyal09 ,
If u want to make work notes mandatory using UI action then u need to make certain modifications in your existing code.
- Click the checkbox for client as true on the UI action. You Ui action will behave like client script instead of Server Side & will accept all client side commands.
- U need to move the above code in script include which should be client callable.
- Call that script include using GlideAjax in your UI action.
- You can use below line whenever u want to make work notes mandatory.
g_form.setMandatory('work_notes',true);
Thanks,
Danish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2024 07:13 AM
Hi @divyal09
To achieve this functionality You can create one Client Script of type - onSubmit. In script you can check if worknote is empty then show message.
function onSubmit() {
//Type appropriate comment here, and begin script below
var workNotesValue = g_form.getValue('work_notes');
if (workNotesValue == "" && !workNotesValue) {
alert('Worknote is mandatory.');
g_form.clearMessages();
g_form.showFieldMsg('work_notes', 'Worknote is mandatory.', 'error');
}
}
Regards,
Akshay