To make variables mandatory when the 'closed complete' or 'closed incomplte' are clicked on a catalog task

rog
Giga Contributor

HI all,

I have a requirement where I have to make certain fields mandatory when clicked on closed complete or closed incomplete buttons on a catalog task.

I have written the following client script on the variable set:

Tyoe : onSubmit

function onSubmit() {

if(g_form.getValue('state') == '3')

{

          g_form.setMandatory("variables.var1", true);

g_form.setMandatory("variables.var2", true);

  }

}

But it is not working. please help.

Thanks

11 REPLIES 11

Suseela Peddise
Kilo Sage

Hi Roger,



Please try onChange client script or UI policy to achieve it .



Also please confirm, Is 'Closed complete' is a button(UI action)?


The on Change script is also not working.


rog
Giga Contributor

Hi Suseela,




Yes it is a UI action.



But these variables appear only on selected tasks,



Thanks


Hi Roger,



If it is an UI action, please follow the steps mentioned by Shloke.



Change the UI action script to make mandatory fields .



Hope this might be helpful.



If the reply was informational, please like, mark as helpful or mark as correct!


shloke04
Kilo Patron

My Bad. Didn't notice you want to make variables mandatory on click of UI Action. The script which I provided above will work for Normal fields. In order to achive your requirement please follow the below steps:



Update your Script as below:



On Line Number 3 Replace g_form.setMandatory('description',true) with the code as mentioned below:



g_form.setMandatory('variables.variable_name', true);



Please find the Updated Script screen shot as below:



find_real_file.png



In the above screen shot Replace "requestor_email" in line Number 3 with your Variable name and this will solve your issue.



Hope this helps.Mark the answer as correct/helpful based on impact.



Regards,


Shloke


Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke