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

Pooja Mallikarj
Kilo Sage

Hi,

I think the issue is with onLoad client script which is hiding u_incident manager field on onload.

Can you pls share your onload client script or try by adding  condition like u_incident manager field is empty.

then only hide u_incident manager field.

Thanks,

Pooja M

Yes aready wrote in same way only but not working. 

This is my script :

function onLoad() {

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

}

Madhav18
Mega Expert

Hi Keerthi,

Can you confirm what exactly is not working as expected in your requirement.

  1. Your UI action is not working -> Is it visible? Is it showing u_incident_manager field on the form and making it mandatory upon clicking UI action?
  2. Your Client script is not working -> u_incident_manager filed is showing on the form even it is empty?


I'm assuming it's second case form the above conversation. please enable filed watcher from your developer options and watch the field u_incident_manager to find out the issue.


If it helps, please mark Correct and 👍 Helpful.

Thanks & Regards,
Madhav

Mohammad Danis1
Giga Guru

Hi Keerthi,

Your UI Action Script is not correct, please replace with the below code :

//Below is the ui action script :
testbutton();
function testbutton(){
current.u_incident_manager= 'true';
action.setRedirectURL(current);
current.update();
}

 

If my reply helped with your issue please mark my reply as Correct & 👍Helpful.


Kind Regards,
Mohammad Danish

 

Mohammad Danis1
Giga Guru

Hi Keerthi,

I got your issue, it's with onLoad Client script as "u_incident_manager" field is of type true/false, it will be either True or False, it's never going to be empty or blank ' ' which means the below client script is not going to work:

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

Secondly, If you will hide u_incident_manager with onLoad Client Script when it's False and then will try to set it visible from UI Action as you'r currently doing, it's always going to HIDE u_incident_manager field because as soon as you'll click on the UI Action button, form will load and OnLoad Client script will do its job. 

I have an alternate solution to your problem where I am setting the Incident Manager Value from UI action and hiding it if it's False from Client Script.

See if it satisfies your requirement :
 

Client Script : 

function onLoad() {
	//Hide Incident Manager Field If it's False
	if(g_form.getValue('u_incident_manager') == 'false'){
		g_form.setVisible('u_incident_manager',false);
	}
}

UI Action :

showfield();

function showfield()
{
	gs.addInfoMessage('Incident Manager Should be true');
	current.u_incident_manager= 'true';
	current.update();
	action.setRedirectURL(current);
}

 

Note : As "u_incident_manager" is a true/false field, setting mandatory won't work because True and False both are valid values for Boolean field.

Thank you!!

If my reply helped with your issue please mark it as Correct & 👍Helpful.


Kind Regards,
Mohammad Danish