Work notes is not updating in UI action in server-side script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2023 01:03 AM
Hi,
I have a requirement to create a UI action in problem table i.e., Cancel Button
If user Click on cancel button, then problem record should closed and problem task which is associated with current problem should closed. Cancel reason should updated in worknotes of problem task but it try different method to update work notes in problem task it not working.
function onModalCancel() {
var reason = prompt('Enter the reason why you want to cancel the problem?');
var sysID = g_form.getUniqueValue();
if (ques) {
g_form.setValue('state', 107); //cancel
g_form.setValue('resolution_code', 'canceled');
g_form.setValue('close_notes', reason);
// g_form.setValue('work_notes',ques);
g_form.save();
gsftSubmit(null, g_form.getFormElement(), 'sysverb_modal_cancel');
}
}
function cancelProblemTask() {
var prb_task = new GlideRecord('problem_task');
prb_task.addQuery('problem', sysID);
prb_task.query();
while (prb_task.next()) {
prb_task.work_notes = reason;
prb_task.state = 157; //closed
prb_task.update();
}
action.setRedirectURL(current);
}
Regards
Mohan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2023 02:14 AM
Hi @Ankur Bawiskar,
I try the script which you sent but it is not updating current record as state to closed and not updating worknotes as well.
Please help me
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2023 02:16 AM
one issue.
you won't get the reason present in client side to server side
do this
function onModalCancel() {
var reason = prompt('Enter the reason why you want to cancel the problem?');
if (reason != '') {
// use GlideAjax here and update the problem task and problem record also
}
}
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader