- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2019 06:36 AM
i am developing a custom application on my PDI and have created a record producer to use on the service catalog. However, each time a user makes the request, i get an error message 'Requested record not found' . Adding the custom role to the user seems to resole the problem. But my organization has almost 5000 users and as such its not feasible to manually add the role to all users. I used the script below, which seems to add the role with 'empty in the tole field.
How do i make this work. and dynamically assign the role to all new users (we have LDAP) integration.
var gr = new GlideRecord("sys_user");
gr.query();
while(gr.next())
{
var role = new GlideRecord('sys_user_has_role');
role.addQuery('user',gr.sys_id);
role.addQuery('role', '<sys_id of Role>');
role.query();
if(!role.next())
{
role.initialize();
role.user = gr.sys_id; role.role = "<sys_id of Role>";
role.insert();
}
}
Solved! Go to Solution.
- Labels:
-
Service Catalog