How to show fields on a form onclick of ui action??

jayasri
Tera Contributor

Hi All,

I want the field to be visible on form when user click on ui action.

I have created onload client script to hide the field on form. In ui action client script im displaying the field using setdisplay. But when i reload the form ,fields are hiding because of onload client script i have created. I want the fields to be on form after clicking ui action. How can i achieve this?

5 REPLIES 5

Omkar Mone
Mega Sage

Hi 

 

You can try this on the onLoad client script.

 

function onLoad() {



var action = g_form.getActionName();
if(action == '<your buttons action_name>')
{
          g_form.setVisible('<your_field_name>',true);
          g_form.setMandatory('<your_field_name',true);

}


 

Let me know.

Regards,

Omkar Mone

Hi Omkar,

 

I'm not giving any ActionName for the ui action.

 

Thanks & Regards,

Jayasri M.

Hi,

How do you track the UI action has been clicked already for that record when the form reloads?

What is the business requirement here for showing the field on click of UI action?

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

Hi Ankur,

 

In OnClick() field im calling a function from script to open ui page.Along with ui page,it should display the fields also.

 

This is a requirement, when customer have some mobile issue and call service desk agent for help, SDA do some checks and store the response form customer in some fields. When click on ui action, it will display ui page and based on response from customer we will fill questions in ui page and submit it. We are saving those responses in form fields.

 

Thanks & Reards,

Jayasri M.