- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-24-2020 04:27 AM
Hi Team,
I have a client script like below to ensure one field is mandatory while closing the task it is working fine but my issues is even if i need to update or save the task then also it is not allowing me to do. In short my requirement is to run the script only when the "close task" button got clicket not the "save" or "update" button/UI action.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-24-2020 04:57 AM
You can check whether which UI action got clicked or not in onSubmit client script as below
give the action name
function onSubmit(){
if(g_form.getActionName() == 'close_sc_task'){
// your code here
}
}
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
‎11-24-2020 04:32 AM
Why havent you directly used Close Task (sc_task) UI action and modified it according to your needs rather than creating on submit client script.
https://yourinstance.service-now.com/sys_ui_action.do?sys_id=79cc847bc611227d01a8092813683b36&sysparm_record_target=sys_ui_action&sysparm_record_row=6&sysparm_record_rows=7&sysparm_record_list=nameSTARTSWITHClose%5Ename%3DClose+Task%5EORDERBYorder
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-24-2020 04:36 AM
The problem here is the workflow have around 14 to 15 tasks and in every task some different variables are mandatory, client script is the only option for me.Is there anyway i can check which button is clicked at the initial level of script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-24-2020 04:43 AM
Make a copy of it and put your code in a function lets say ...
in onClick : clsTsk() ( you use this which you will call below)
Condition : modify it as per your needs.
function clsTsk()
{
Put the code here which you have written above
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-24-2020 04:46 AM
Hi Sreejith,
Before checking for Short Description, check for State of the Task - "Closed" or not.
Regards,
Deepak K