On submit client script only for "close task" UI action

sreejith05
Giga Expert

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.

 

find_real_file.png

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@sreejith05 

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

}

}

find_real_file.png

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

6 REPLIES 6

Ct111
Tera Sage

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

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

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 

 

}

Deepak K
Mega Guru

Hi Sreejith,

Before checking for Short Description, check for State of the Task - "Closed" or not.

Regards,

Deepak K