Unable to Hide field with UI Policy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-01-2023 06:28 AM
I have created a UI policy to hid a field if the project us sub project but its not working.
Also there's a client script working for the same field but for different conditions. For testing I just deactivated the client script and then my UI policy worked but eventually I cant deactivate the Client script. How can I fix this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-01-2023 07:46 AM
Hi,
Can you share what the client script is doing. Seems to be something in there. Remember that you can't hide a field if it's marked as mandatory.
//Göran
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-01-2023 09:04 AM
Hi I can't share the exact script as it contains sensitive data but can tell you the scenerio.
There's a Field(suppose Field_1) in project table which has 3 choices A,B,C. if A or B is selected (Field_E) has to be mandatory and be visible and for C it has to be hidden. so simply used g_form.setMandatory(true) and g_form.setDisplay(true) and vice-versa for Choice C.
Now the next requirement is to hide (Field_E) if the project record is sub project (parent != empty).
Now the UI policy to hide Field_E is not working. Even though I have set madatory as well visible as false in UI Policy.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-01-2023 09:57 PM
The similar scenario client script:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
var Type = g_form.getValue('u_type');
if(Type == 'choice_1'){
g_form.setMandatory('u_code', true);
g_form.setDisplay('u_code', true);
}
else if(Type == 'choice_2'){
g_form.setMandatory('u_code', true);
g_form.setDisplay('u_code', true);
}
else if(Type == 'choice_3'){
g_form.setMandatory('u_code', false);
g_form.setDisplay('u_code', false);
}
else{
g_form.setMandatory('u_code', false);
g_form.setDisplay('u_code', true);
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-03-2023 12:18 AM - edited ‎03-03-2023 12:18 AM
Hi @Community Alums,
Since fields are only visible in Master project, make sure your client script only runs for the Master project.
in that way, client script execution to make the field mandatory or to display will not be executed in Sub project.
Another approach is that you can remove the code form the Client script and create new UI policy which will run for Top project only to mandate/display the field.
This way you can hide the fields which are not required in sub project.
Or else you can use client script itself to make the field hidden in case of sub project. In this case you need to have a glide record of the current record to check if parent is empty or not.
Let me know if was helpful.
Thanks,