Catalog item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2024 04:32 AM
Type : Select Box (field1) , Question name : operations , Choices : Companies , Activites , Opportunities.
Type : Select Box (field2), Question name : access , Choices : Read , Edit , Export , Explore , EPF.
If user select role is : Admin then field 1 : should be visible all choices, field 2 select only visible those choices :Read , Edit ,EPF.
Any idea how to hide the choices.
Usint the Onchangescript but working any idea help me proper code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2024 04:47 AM
Since this is a select box field you can use
g_form.removeOption('field2_name', 'option value');
one line of code for each value to remove. Be sure to use the select box choice value, not the label. Is there a variable where a user can select the role admin, or are the choices dependent on the current user having the role of admin? If it's the latter you can use
if (g_user.hasRoleExactly('admin')) {
If you're still stuck, post your script attempt using the insert code icon </>, and we'll get it sorted.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2024 05:16 AM
You can refer the below onChange client script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var role = g_form.getValue("role");
if (role == "admin") {
g_form.removeOption("access", "Export");
g_form.removeOption("access", "Explore");
}else{
g_form.addOption("access", "Export", "Export");
g_form.addOption("access", "Explore", "Explore");
}
}
If this solution helps you then, mark it as accepted solution ✔️ and give thumbs up 👍!