- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2024 10:18 PM
I need to make many fields mandatory but only for 2 views.
I can see there is a field in the UI Policy for view. but I can add only 1 view in the field.
I need to add 2 views in it.
Can we achieve it only if we create 2 individual UI policy.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2024 10:29 PM
Hello @Deborah Brown L ,
One way to achieve it by creating on load client script and using g_form.getViewName() method to get the current view as follows-
Further you can build if condition to make fields mandatory for those particular views.
var view = g_form.getViewName();
if(view == 'default' || view == 'abc'){ //Replace the view name
g_form.setMandatory('field_name', 'value');
}
If my answer solves your issue, please mark it as Accepted✔️ and Helpful👍 based on the impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2024 10:26 PM - edited 07-08-2024 11:13 PM
Hi @Deborah Brown L,
In scripts, you can use g_form.getViewName().
if (g_form.getViewName() == '<view_name_1>') { //different set of fields use this, else you can add the other view condition with ||
g_form.setMandatory('<field_name>', true);
//any other
} else if (g_form.getViewName() == '<view_name_2>'){
g_form.setMandatory('<field_name>', true);
//any other
}
Mark the response correct and helpful if the answer assisted your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2024 10:29 PM
Hello @Deborah Brown L ,
One way to achieve it by creating on load client script and using g_form.getViewName() method to get the current view as follows-
Further you can build if condition to make fields mandatory for those particular views.
var view = g_form.getViewName();
if(view == 'default' || view == 'abc'){ //Replace the view name
g_form.setMandatory('field_name', 'value');
}
If my answer solves your issue, please mark it as Accepted✔️ and Helpful👍 based on the impact.