- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2023 07:54 AM
I tried creating a UI action to add the user to the group but the button won't do anything on click.
I created the UI action on the sys_user table and added the below script but nothing is happening. Nothing in the logs either. Any suggestions?
var rec = new GlideRecord('sys_user_grmember');
rec.initialize();
rec.user = current.user.sys_id;
rec.group = '9da403d8979fdd103749312e2153af7e'; //group ABC
rec.insert();
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2023 08:26 AM
Hi @GB14
can you please uncheck client checkbox and try that will work.
If my answer solved your issue, please mark my answer as ✅ Correct & 👍Helpful based on the Impact.
Regards,
Ranjit Nimbalkar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2023 08:10 AM
Hi @GB14 ,
->> Verify that the group ID you are using in the script is correct and exists in the system. You can find the correct group ID by navigating to the group record and checking its sys_id value in the URL.
->>Check the ACLs (Access Control Rules) for the sys_user_grmember table to ensure that the current user has the necessary privileges to create new records in this table.
->>Check the UI action's conditions to make sure they are not preventing the action from being executed. You can try temporarily removing the conditions to see if the UI action works.
->>Add some error handling to your script to display a message to the user if the insert operation fails.
For example:
var rec = new GlideRecord('sys_user_grmember');
rec.initialize();
rec.user = current.user.sys_id;
rec.group = '9da403d8979fdd103749312e2153af7e'; //group ABC
if (rec.insert()) {
gs.addInfoMessage("User added to group successfully.");
}
else {
gs.addErrorMessage("Failed to add user to group.");
}
Thanks,
Ratnakar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2023 08:25 AM
Hello Ratnakar,
I tried but nothing happens on click. Nothing in the logs either.
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2023 08:39 AM - edited 05-10-2023 08:41 AM
Try configuring your UI Action as below.