how to restrict one fields in form section.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2024 06:16 AM
In Business application ( cmdb_ci_business_app ) form under compliance section there are some fields called "Business Criticality and "IT Tier Classification"
in section contacts we have a field called IT application owner which is a mandatory field.
give access to 'Business criticality' field for IT application owner and all other fields should be read only, but when GRCT group logged in, then Business criticality and IT Tier classification both fields should be accessible, and rest fields should be read-only. how can I achieve this, please help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2024 06:29 AM
Try onload client script like below :
function onLoad() {
var currentUser = gs.getUser();
var isITAppOwner = gs.hasRole('it_application_owner');
var isGRCTGroup = gs.hasRole('grct_group');
if (isITAppOwner) {
var getFields = g_form.getEditableFields();
for(var i=0;i<getFields.length;i++)
{
g_form.setReadOnly(getFields(i),true);
}
g_form.setReadOnly('business_criticality', false);
} else if (isGRCTGroup) {
var getFields2 = g_form.getEditableFields();
for(var i=0;i<getFields2.length;i++)
{
g_form.setReadOnly(getFields2(i),true);
}
g_form.setReadOnly('business_criticality', false);
g_form.setReadOnly('it_tier_classification', false);
}
}
☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2024 09:41 AM
Thank you for the quick reply.
Here IT application owner might be anyone, so we can't rely on roles, more over gs is not working in on load,
can you suggest any other way
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2024 06:41 AM
Hi @prash4 ,
I checked your problem I got similar requirement please check below link
Please mark my answer correct and helpful if this works for you
Thanks and Regards
Sarthak