- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā06-14-2023 02:29 AM
I need to get caller loaction for the caller in the incident table.We have this related client script in Native UI after changing the UI type to All still the location is not auto populated.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā06-14-2023 02:56 AM
Hi @VISWANATH KAMAL ,
I trust you are doing great.
Here's an example solution:
- Open the incident table in ServiceNow Native UI.
- Navigate to the client script section and locate the related client script.
- Edit the script and ensure the UI type is set to "All" so that it functions correctly across different user interfaces.
- Add the following code snippet to retrieve the caller's location and populate it automatically:
function onLoad() {
var callerId = g_form.getValue('caller_id');
if (callerId) {
var callerGr = new GlideRecord('sys_user');
if (callerGr.get(callerId)) {
var location = callerGr.getValue('location');
g_form.setValue('location', location);
}
}
}
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā06-14-2023 02:52 AM
Hi @VISWANATH KAMAL ,
I trust you are doing great.
- Navigate to the Incident table in ServiceNow.
- Open the related client script for the Native UI.
- Update the client script code to include the logic for retrieving and populating the caller's location.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === '') {
return;
}
var callerSysId = g_form.getValue('caller_id');
var locationField = g_form.getField('location');
if (callerSysId) {
var caller = new GlideRecord('sys_user');
if (caller.get(callerSysId)) {
var location = caller.getValue('location');
if (location) {
g_form.setValue('location', location);
} else {
locationField.clearValue();
}
}
} else {
locationField.clearValue();
}
}
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā06-14-2023 02:56 AM
We already have the client script to get the caller location.It is working in Native UI but not in Service operations workspace.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-27-2024 11:34 PM
Hi Viswanath Kamal ,
To work Client Script in Specific View , Uncheck the Global Field Checkbox in Client Script Form and Then View Field will be Visible and select the view which is required (for Service Operations Workspace ) Enter sow View
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā06-14-2023 02:56 AM
Hi @VISWANATH KAMAL ,
I trust you are doing great.
Here's an example solution:
- Open the incident table in ServiceNow Native UI.
- Navigate to the client script section and locate the related client script.
- Edit the script and ensure the UI type is set to "All" so that it functions correctly across different user interfaces.
- Add the following code snippet to retrieve the caller's location and populate it automatically:
function onLoad() {
var callerId = g_form.getValue('caller_id');
if (callerId) {
var callerGr = new GlideRecord('sys_user');
if (callerGr.get(callerId)) {
var location = callerGr.getValue('location');
g_form.setValue('location', location);
}
}
}
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi