Hide Form Section and Section Fields

ar1
Kilo Sage

Hello All,

 

My Requirment:

Under Form Section almost 15 fields are available and we need to hide them based on the selected category.

And also few fields are mandatory before saving the form and few fields are mandatory after saving the form.

we tried UI policy to make fields mandatory before and after saving the form and it's working perfectly with the conditions.

But we're unable to hide the fields based on the selected category, it's showing all the fields irrespective category.

OR

We want to Hide the section and display the section based the selected category.

Advance thanks.... 

1 ACCEPTED SOLUTION

ar1
Kilo Sage

HI All,

 

Thanks you so much for all your inputs.

Instead of hiding and showing the fields we hide the section And display the section with the required fields based on the category.

Below script we tried in Ui policy to hide the section. 

Condition : Category is X

if true:

function onCondition() {

g_form.setSectionDisplay('section_name',false);
var sections = g_form.getSectionNames();
for(var i=0; i<sections.length; i++)
{
if(i == '0')
{
g_form.setSectionDisplay(sections[i],false);

g_form.setMandatory('incident',false);
g_form.setMandatory('inc',false);
g_form.setMandatory('vehicle',false);
}
}
}

If False:

 

function onCondition() {

g_form.setSectionDisplay('section_name',false);
var sections = g_form.getSectionNames();
for(var i=0; i<sections.length; i++)
{
if(i == '0')
{
g_form.setSectionDisplay(sections[i],true);


g_form.setMandatory('incident',true);
g_form.setMandatory('inc',true);
g_form.setMandatory('vehicle',true);

}
}
}

Once again thank you All..

View solution in original post

9 REPLIES 9

A UI Policy base on category should work fine as long as you do not have the same fields being hidden by different UI Policies.  So for example if field A needs to be hidden for Category X, Y, and Z do not create 3 UI Polices create one and in your conditions make sure you have category is one of and then select the three categories.

Hello Brian,

Thank you so much for your timely support....

 

As mentioned above we created in the same and it's working

 

but the problem was fields are not hiding based on the selected category and for each category different fields are there to hide.

Example:

1. A category -- Hide X,Y,Z

2. B Category --- Hide E,F,G

3. C category -- Hide K,L,M

Probably because you have UI Policies to make the mandatory after save which technically is not possible unless you have another condition.  If you want to have them hide but then be mandatory after save I think you need to make a new field that you do not display on the form.  Simple true/false field should work.  Make it true using a business rule after save and then make you condition for mandatory after save as category A and field is true. 

Dubz
Mega Sage

If you use UI policies for this you'll need to have one for each category, depending on the number of categories you have this will get quite difficult to administer and configuring them so there are no conflicts will be complex and time consuming. 

I think an onChange client script would be the best solution. How you configure it depends on how many categories you have, if it's only a few then you could just use if/else statements in the client but if you have quite a few it could get a bit lengthy as each statement will need to define whether each of the 15 fields is visible and mandatory so that it's correct each time the field is changed. 

If you have a lot of categories it'd be easier to make a lookup table and call a script include to get the required values per field.

ar1
Kilo Sage

HI All,

 

Thanks you so much for all your inputs.

Instead of hiding and showing the fields we hide the section And display the section with the required fields based on the category.

Below script we tried in Ui policy to hide the section. 

Condition : Category is X

if true:

function onCondition() {

g_form.setSectionDisplay('section_name',false);
var sections = g_form.getSectionNames();
for(var i=0; i<sections.length; i++)
{
if(i == '0')
{
g_form.setSectionDisplay(sections[i],false);

g_form.setMandatory('incident',false);
g_form.setMandatory('inc',false);
g_form.setMandatory('vehicle',false);
}
}
}

If False:

 

function onCondition() {

g_form.setSectionDisplay('section_name',false);
var sections = g_form.getSectionNames();
for(var i=0; i<sections.length; i++)
{
if(i == '0')
{
g_form.setSectionDisplay(sections[i],true);


g_form.setMandatory('incident',true);
g_form.setMandatory('inc',true);
g_form.setMandatory('vehicle',true);

}
}
}

Once again thank you All..