- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2020 11:08 PM
I need to check one "checkbox" below before fulfiller click "close task" from banner to close the task.
When I change task state, OnSubmit script works fine but when task is closed from banner, OnSubmit script do not work.
Please help
Thanks
Mohammad
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2020 11:34 PM
Hi,
2 approaches
1) make that variable as Mandatory for Catalog Task
OR
2) update the OOB UI action as below
Note: give the catalog item sys_id for whose Task you want to run this for
function closeTask(){
var catItemSysId = g_form.getReference('request_item').cat_item;
if(catItemSysId == 'Your Catalog Item Sys ID'){
var variableValue = g_form.getValue('checkbox_variableName');
if(variableValue == ''){
alert('Please select the checkbox before closing the task');
return;
}
}
g_form.setValue('state', 3);
//Call the UI Action and skip the 'onclick' function
gsftSubmit(null, g_form.getFormElement(), 'close_sc_task');
}
//Code that runs without 'onclick'
//Ensure call to server-side function with no browser errors
if (typeof window == 'undefined')
updateTask();
function updateTask(){
current.state = 3;
current.update();
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2020 11:39 AM
Hi Ankur,
I believe this script will work. This code will go for UI Action? How to run this script?
Regards,
Mohammad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2020 02:19 PM
Thanks Ankur, what will be the condition for "UI Action"?
Will UI Action below will work?
Name: Close task
Table: sc_task
Order: 100
Action name: close_sc_task
Active: true
Form button: true
Condition: ?
Client: true
OnClick: Closetask()
Script:
Your Script above
Thanks,
Mohammad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2020 10:20 PM
Hi,
just keep the same condition which is present OOB
current.state.canWrite() && current.state != -5 && current.state < 3 && current.approval != 'requested'
Also update OnClick as : closeTask()
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2020 09:31 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2020 09:37 AM
Hi,
Close task is on sc_task only
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader