- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-08-2023 10:50 PM
In the Change Request form, the 'Category' field depends on the 'u_area' field. When a user selects 'UTA' in the 'u_area' field, four options ('Asset Replacement', 'Asset Transfer', 'Asset Name Change', and 'Asset Disposal') are available in the 'Category' field.
However, a specific requirement entails that if the user selects 'UTA' in the 'u_area' field and possesses the role of 'Disposal Manager', only the 'Asset Disposal' option should be visible in the 'Category' field along with the others, but not visible otherwise.
This is working for other fields that are not dependent, however not working on dependent fields. Need your suggestion
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-09-2023 05:39 AM
In both cases the system is retrieving the dependent category choices when the area changes, likely after your script has completed. Try setting an interval or timeout prior to the clear or remove. Since it's reloading the choices with every change, you should just need to remove the one choice if they don't have the role - no need to clear all and re-add the other choices:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var uArea = g_form.getValue('u_area');
if (uArea ==='8ba3a6aa47c1b9185f03bd01336d43bc') {
var isAdmin = g_user.hasRole('Disposal Manager');
if (!isAdmin) {
alert ('not Admin');
setInterval(function() {
g_form.removeOption('category', 'Asset Disposal');
}, 2000);
}
}
}
wrapping the removeOption in a setInterval function may also work in a UI Policy script, depending on the timing of a UI Policy execution vs Client Script and the dependent field retrieval.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-09-2023 08:09 PM
@Brad Bowman Thank you for the solution. This solution is working fine for me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-10-2023 04:11 AM
You are welcome.