How to visible and mandatory field once clicked on Button

Santoshi5
Giga Guru

Hi Developers,

I want to  make visible and mandatory ,explanation field once clicked on Reject button when we fill the details state changes to complete and record should be save.

Below is the UI Action &client script

client sacript:Onload()

function onLoad() {
//Type appropriate comment here, and begin script below

g_form.setVisible('u_explanation',false);

}

 

Ui Action :

find_real_file.png

find_real_file.png

 

when i clicked on button field is visible and throwing error message but not changing state as nothing is happened .. 

1 ACCEPTED SOLUTION

Great!  It looks like you marked your own response as the correct answer, which may be confusing to others that read this later.

I felt I covered that above pretty well (first) and included the script which pointed you in right direction on combination of client+server side code

If my answer solved your issue, please mark my answer as Correct & 👍Helpful based on the Impact.

Regards
Ankur

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

View solution in original post

8 REPLIES 8

Dhananjay Pawar
Kilo Sage

Hi,

Can you add g_form.setValue('u_quality_state','4'); in client side and check it once.

Thanks,

Dhananjay.

AMIT SHISHODIA2
Giga Guru

Hi Santoshi,

Please use g_form.getvalue('u_explaination') instead of u_explaination
It will work
Please mark correct and helpful if it resolves your issue

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

your UI action is combination of client+server side code

Syntax is incorrect so please update as below

function reject(){

g_form.setVisible('u_explanation', true);
g_form.setMandatory('u_explanation', true);

g_form.addErrorMessage('Your message here');

}

gsftSubmit(null, g_form.getFormElement(), 'reject');

if(typeof window == 'undefined')
   statevalue();

function statevalue(){

// your server side code here

}

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

Tried but no luck