Validate group member with lodged in user and set field value make read only
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
5 hours ago
GIVEN the user is a member of the a group and check user is current logged in user
WHEN the user opens the record producer then Field one choice set to specific value and make field ready only
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
5 hours ago - last edited 5 hours ago
Hi @vinnus
You can call the call the script include using GlideAjax in the catalog client script and in the script inlcude enable the GlideAjax enabled checkbox to true
Client script:
function onLoad() {
var ga = new GlideAjax('CheckUserGroup');
ga.getXMLAnswer(function(answer) {
if (answer === 'true') {
// Set Field 1 to the required choice value
g_form.setValue('field_one', 'specific_value');
// Make Field 1 read-only
g_form.setReadOnly('field_one', true);
}
});
}
Script include:
var CheckUserGroup = Class.create();
CheckUserGroup.prototype = Object.extendsObject(AbstractAjaxProcessor, {
isUserMember: function() {
var isMember = gs.getUser().isMemberOf('GROUP_SYS_ID');
return isMember;
},
type: 'CheckUserGroup'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
Hi @vinnus ,
To achieve this requirement, we can use an onLoad Catalog Client Script along with a Client Callable Script Include.
1. Catalog Client Script
Use an onLoad Catalog Client Script on the Record Producer.
The script checks whether the logged-in user belongs to the required group. If the user is a member:
- Set Field 1 to the required choice value in my case setting the value to "Choice 2".
- Make Field 1 read-only.
2. Client Callable Script Include
Since the group membership needs to be validated against sys_user_grmember, use a Client Callable Script Include:
Result :
Populating the logged in user on the "Assigned to" field and updating the choice field
Please check below screenshots
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Iftekhar