Inbound email with users information

DevtoSME
Giga Guru

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
    }
}

 

1 ACCEPTED SOLUTION

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.

View solution in original post

3 REPLIES 3

Najmuddin Mohd
Mega Sage

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.

Hi both fields are reference field from the users profile and are custom fields on the incident form.

 

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.