- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-03-2024 01:23 PM
I'm tryin to add in the "callers" location and business phone to populate the fields on the incident form. I'm able to get most fields like assignment group and short description for populate but not these 2 fields.
they are both custom fields. does anyone have an answer. I will attach the script portion below.
// Check if the user is registered
if (current.caller_id) {
var userGR = new GlideRecord('sys_user');
if (userGR.get(current.caller_id)) {
current.u_caller_location = userGR.location; // location
current.u_business_phone = userGR.phone; // phone
current.assignment_group = '9a758965321456987892326d3fbb351c'; // group name
} else {
gs.info("User not found: " + current.caller_id); // Log if user is not found
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-04-2024 09:53 AM - edited ‎10-04-2024 10:26 PM
I believe the business phone field on the user table is not reference field. So, it should not be reference field.
Add the below code,
// Check if the user is registered
if (current.caller_id) {
var userGR = new GlideRecord('sys_user');
if (userGR.get(current.caller_id)) {
current.u_caller_location = userGR.location.getValue(); // Custom Reference Field
current.u_business_phone = userGR.phone.toString(); // Custom String field
current.assignment_group = '9a758965321456987892326d3fbb351c'; // group name
} else {
gs.info("User not found: " + current.caller_id); // Log if user is not found
}
}
If the above information helps you, Kindly mark it as Helpful and Accept the solution.
Regards,
Najmuddin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-03-2024 05:56 PM
HI @DevtoSME ,
Is u_caller_location a reference field or a string field. If reference, can you use userGr.location.sys_id. If string field, can you use userGr.location.getDisplayValue().
Also, just log the values so that you understand what values are these actually fetching.
gs.log('From Email: User Location - ' + userGr.location);
gs.log('From Email: User Phone - ' + userGr.phone);
Hope this helps.
Regards,
Najmuddin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-04-2024 07:01 AM
Hi both fields are reference field from the users profile and are custom fields on the incident form.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-04-2024 09:53 AM - edited ‎10-04-2024 10:26 PM
I believe the business phone field on the user table is not reference field. So, it should not be reference field.
Add the below code,
// Check if the user is registered
if (current.caller_id) {
var userGR = new GlideRecord('sys_user');
if (userGR.get(current.caller_id)) {
current.u_caller_location = userGR.location.getValue(); // Custom Reference Field
current.u_business_phone = userGR.phone.toString(); // Custom String field
current.assignment_group = '9a758965321456987892326d3fbb351c'; // group name
} else {
gs.info("User not found: " + current.caller_id); // Log if user is not found
}
}
If the above information helps you, Kindly mark it as Helpful and Accept the solution.
Regards,
Najmuddin.