On click of ui action button the corresponding field is getting disappear

keerthi19
Tera Guru

Hi All,

I am trying to create one button in incident table. Based the button selection one field should be visible and mandatory.

But if i select the  ui action in incident form its working but when i submit the incident the particular field is getting disappear. Not sure how its happening...Any idea will be appreciated..

This is my ui action condition :

((current.state !=6) && (current.u_major_incident == false) && (gs.hasRole("admin")) || gs.getUser().isMemberOf(­'database') || current.u_major_incident == true)

Below is the ui action script :

function testbutton(){

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

}

And i wrote on onload client script to hide the u_incident manager field on onload. 

But somehow its not working ..can someone help me to resolve the issue.

 

 

9 REPLIES 9

Kieran Anson
Kilo Patron

Hi Keerthi,

If you've got an onLoad client script that is set to hide the u_incident_manager field, it's always going to hide it. I presume you're wanting the field to be visible onLoad if it is no longer empty, i.e UI action has been previously pressed.

if(g_form.getValue('u_incident_manager') == ''){
g_form.setVisible('u_incident_manager',false);
}

If my reply helped with your issue please mark helpful 👍 and correct if your issue is now resolved.
By doing so you help other community members find resolved questions which may relate to an issue they're having.

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Keethi,

2 things to check

1) button to be shown when u_incident_manager -> is true

2) on click of that button the field should be mandatory?

What are you trying to achieve? please explain?

Is that a true/false field? if yes then setting mandatory won't work as True and False both are valid values for Boolean field

Regards
Ankur

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

Hi Ankur,

There are two things here. 

find_real_file.png

1. So when i select the "Test Button" the Incident Manager field should be visible and mandatory and it should be visible in the form after submitting the form too.

2. And When i select the Major incident check box then only the "Test Button" should visible in the form otherwise it wont visible in the form(If it happens onchange of the checkbox then it would be great). Right now it working after submit.

I am expecting this two points only.. So for this i tried the above mentioned ui action and client script its working to show the field but when i submit the form the incident manager field disappear..Something is overriding i guess but unable to find out.. 

To hide onload of the form wrote ui policy without any condition.

To button visibility wrote the above ui action..

 I hope its clear now...

Hi Keethi,

please find response below

1) incident manager field is a checkbox i.e. boolean with value as True/False

You cannot make it mandatory since both True and False are valid values

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