On click of ui action button the corresponding field is getting disappear
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2020 03:45 AM
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.
- Labels:
-
Script Debugger
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2020 04:32 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2020 04:37 AM
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);
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2020 05:19 AM
Hi Keerthi,
Can you confirm what exactly is not working as expected in your requirement.
- 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?
- 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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2020 09:24 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2020 03:46 AM
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