- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2023 06:30 AM - edited 09-25-2023 09:23 AM
Below client script code opens new record on user table in agent workspace UI but I also want to auto populate fields like first_name, department, title on the user form that opens in agent workspace UI
Currently, form opens but fields are not getting auto populated
var url = "now/workspace/agent/record/sys_user/-1/first_name=testing";
top.window.open(url);
How to do that ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2023 09:21 AM
Below client script code opens new record on user table in agent workspace Ui but I also want to auto populate fields like first_name, department, title on the form that opens.
var url = "now/workspace/agent/record/sys_user/-1/first_name=testing";
top.window.open(url);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2023 07:00 AM - edited 09-25-2023 07:03 AM
Hi @Snehal13
If my understanding is correct then you want to update the user record from URL.
Can you try using onLoad client script on User Table
function onLoad() {
g_form.addInfoMessage("loading");
//get URL
var gUrl = top.location.href;
g_form.addInfoMessage(top.location.href);
/* check if link contains "workpace" string -
so only run this script if incident is updated by link
OR you can use any unique word from URL*/
if (gUrl.toString().includes('workspace')) {
//get the Short description & department value
var getShort = gUrl.split('&')[2].split('=')[2];
var getDept = gUrl.split('&')[3].split('=')[1];
/* update the form */
g_form.setValue('short_description', getShort);
g_form.setValue('department, getDept);
g_form.save();
}
}
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2023 08:10 AM
Not update. Open a workspace record for user table and auto populate fields like name and department
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2023 09:21 AM
Below client script code opens new record on user table in agent workspace Ui but I also want to auto populate fields like first_name, department, title on the form that opens.
var url = "now/workspace/agent/record/sys_user/-1/first_name=testing";
top.window.open(url);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2023 07:12 AM
Hi @Snehal13 ,
Try this.
https://<Instance_name>.service-now.com/sys_user.do?sys_id=-1&sys_target=sys_user&sysparm_query=first_name%3danvesh%5edepartment%3d5d7f17f03710200044e0bfc8bcbe5d43&sysparm_view=Workspace
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2023 08:11 AM
Department not getting auto populated. Name getting auto filled. And it must open in agent workspace mode. The url you shared is for native ui