Client script

tushar_ghadage
Tera Contributor

Hi guys , 

 

State choice = Closed should be hidden from the form if State = new, for Change Tasks

 

for that I have written on load client script :

 

function onLoad() {
   //Type appropriate comment here, and begin script below
    g_form.addOption('state','3');

   if(g_form.getValue('state') == '1')
   {
    g_form.removeOption('state','3');
   }
}
its working but for other option too showing the choice ' closed 'hidden ..
 
any correction guys I  need to make??
 
thankss !!
12 REPLIES 12

Chaitanya ILCR
Kilo Patron

Hi @tushar_ghadage ,

 

Try this

 

function onLoad() {
    //Type appropriate comment here, and begin script below
    // g_form.addOption('state', '3'); you don't need this
	

    if (g_form.getValue('state') == '1') {
        g_form.removeOption('state', '3');
    }
}

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

 

Anshul Shrivast
Tera Contributor

Hi @tushar_ghadage ,

 

Try to add else part in script to show the closed state.

 

Or remove this line from script - g_form.addOption('state','3');

 

Please mark my answer correct if it helps you.

 

Thanks

Anshul

yes i tried the same but its hiding it for all the options 

Screenshot (172).png

Hey @tushar_ghadage ,

 

As we can see in your screenshot, the mandatory fields are empty in the form, which mean you have not saved the form. You need to save the form to make it work as it's onLoad client script and not onChange.


***************************************************************

Hope the answer helps!

Happy Learning!