Populate the catalog variable with User personal Detail
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi,
I have an issue with the User table where we have an Access Control List (ACL) defined for the Personal Detail section. This ACL specifies two roles that are required for accessing certain information.
I also have a catalog item that includes user details such as Home Location and Joining Date. However, when I submit this catalog item for a user who does not possess the specified roles in the ACL, the relevant variables do not get populated.
I have tried several approaches, including:
1. Dot Walk Method
2. OnChange Client Script with a Script Include using GlideAjax
3. Utilizing a custom action in the Flow
I am wondering if it is possible to populate the variables in the catalog item for which we do not have read access to the table. If it is possible, could anyone suggest which method I should use to accomplish this?
For your reference, I have attached the script I am using in the custom flow action.
Thanks,
Subash
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
you are using GlideRecordSecure and hence ACL will get evaluated and block
you should use GlideRecord so that ACLs are bypassed during GlideAjax
Same with the server side script use GlideRecord
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi @subashds6515 ,
If i'm not wrong you want to set the catalog variable before submit it, so for that you need to write the
Client script- (Onload)
function onLoad() {
var userSysId = g_form.getValue('user'); // Assuming 'user' is a field on your form
// Check if the userSysId is valid
if (userSysId) {
// Call the Script Include using GlideAjax
var ga = new GlideAjax('GetUserDetails');
ga.addParam('sys_id', userSysId); // Pass the user Sys ID to the Script Include
ga.addParam('sys_action', 'getUserInfo'); // Call the method from Script Include
// Make the asynchronous call and process the response
ga.getXMLAnswer(function(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
var userDetails = JSON.parse(answer);
if (userDetails.home_location) {
g_form.setValue('home_location', userDetails.home_location); // Set Home Location
}
if (userDetails.joining_date) {
g_form.setValue('joining_date', userDetails.joining_date); // Set Joining Date
}
});
}
}
And the Script Include-
var GetUserDetails = Class.create();
GetUserDetails.prototype = {
initialize: function() {
},
// This method will fetch the user details
getUserInfo: function(userSysId) {
var userGr = new GlideRecord('sys_user');
if (userGr.get(userSysId)) {
return {
home_location: userGr.home_location,
joining_date: userGr.joining_date
};
}
return {};
},
type: 'GetUserDetails'
};
Hope that will solve your issue, please test this in your end
If my response is helpful please mark as helpful and accept the solution
Thank you!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
59m ago
Hi @subashds6515 ,
You are using GlideRecordSecure which is forcing ACLs to execute before returning data.
Change to GlideRecord to provide access.
Also, make sure the ACL on script include provide access to users to execute script include.
Thanks
Anand
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
13m ago
Hi @Ankur Bawiskar, @Nawal Singh, @ Anand2799,
I am currently using a custom action in the flow. I changed GlideRecordSecure to GlideRecord, but I still am not able to retrieve the value.
The reason for this change is that I want to populate two fields. In the future, we may have a requirement to populate user details in another catalog item, and this custom action will facilitate that.
Here are the inputs I plan to use along with the script:
Is it possible to achieve this?
Thanks,
Subash