- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2024 09:09 PM
Good evening!
I am currently helping to configure the Service Operations Workspace for our organization. To make it easier for the agents, I developed a UI action to create a user from the interaction if they do not exist. My script works fine to create the new user, but I was hoping to find a way to create the user and then link this new user back to the interaction record (so the agent doesn't need to re-select and find the created user). Here is my current UI Action script (I currently have a button to "Create New User" displayed on the interaction form - it is a boolean field that needs to be checked to show the additional fields to fill out to create the user)
Any ideas or am I crazy?
Thank you!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2024 08:19 PM
Hello @kristenmkar
You can get the created user record sys_id like below:
var userGr = new GlideRecord('sys_user');
if (current.u_user_not_found == true) {
userGr.newRecord();
userGr.setValue('first_name', current.opened_for.first_name);
userGr.setValue('last_name', current.opened_for.last_name);
userGr.setValue('user_name', current.opened_for.email);
userGr.setValue('u_employee_type', current.opened_for.u_employee_type);
userGr.setValue('email', current.opened_for.email);
userGr.setValue('title', current.opened_for.title);
userGr.setValue('phone', current.opened_for.phone);
userGr.setValue('u_syscom', current.opened_for.u_syscom);
userGr.setValue('u_edipi', current.opened_for.u_edipi);
userGr.setValue('u_ech_iii', current.opened_for.u_ech_iii);
userGr.setValue('u_business_area', current.opened_for.u_business_area);
userGr.setValue('u_org', current.opened_for.u_org);
userGr.setValue('u_org_code', current.opened_for.u_org_code);
userGr.setValue('u_org_code_title', current.opened_for.u_org_code_title);
userGr.setValue('u_branch_of_service', current.opened_for.u_branch_of_service);
userGr.setValue('u_command_location', current.opened_for.u_command_location);
userGr.setValue('u_remote_user', current.opened_for.u_remote_user);
userGr.setValue('location', current.opened_for.location);
userGr.setValue('department', current.opened_for.department);
var sysID = userGr.insert(); //store the sys_id
current.opened_for = sysID; //assigning the newly created user record sys_id
current.update(); //update the interaction record
} else {
gs.addInfoMessage("You must check " + "'User Not Found' " + "to Create a New User or remove referenced user in Opened For field.");
}
Is it okay for you guys to create user's via script? How do you handle users in your SN instance?
Murthy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2024 04:16 PM
So, you want to populate back the user details back to interaction.If yes which details you want to populat? Can you share any screenshots to know more better?
Murthy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2024 07:45 PM
No worries, I got it figured out! I appreciate all your help!