How can I display the first name, last name, and email address in the Name column for the user table.

JR Guieb
Tera Expert

How can I display the first name, last name, and email address in the Name column for the user table.   Currently the the requested for variable is referencing the users table and displays the name field which only has the user's first and last name.   The issue we are having is that we have some users with the same name and the end user submitting an incident or request cannot distinguish which person to choose.   I do not have a good grasp at scripting so any help would be great.

Here is what we have for the script for the name column:

if (current.first_name.nil() && current.last_name.nil() && !current.name.nil()) {

  var names = current.name.toString().split(" ");

  if (names.length > 1) {

      current.first_name = names[0];

      names.shift();

      current.last_name = names.join(" ");

  } else

      current.last_name = names[0];

}  

if(current.first_name.nil()) {

      current.last_name;

  } else {

      current.first_name + ' ' + current.last_name;

  }

1 ACCEPTED SOLUTION

Brad Bowman
Kilo Patron
Kilo Patron

I was experiencing the same display discrepancy between the Service Catalog and ESS, and the new Service Portal until I made my Variable attributes the following:



ref_auto_completer=AJAXTableCompleter,ref_ac_columns=email,ref_ac_columns_search=true,ref_ac_order_by=name



The search and order by may not be necessary.   Now I am seeing name and email in the reference drop-down - though it seems to stack the email address beneath the name, not to the right.


View solution in original post

11 REPLIES 11

Brad Tilton
ServiceNow Employee
ServiceNow Employee

I don't think I would change up the name field on the user table just for your requested items. I would consider using some reference attributes on your requested for reference variable as described in the following article.



http://wiki.servicenow.com/index.php?title=Auto-Complete_for_Reference_Fields


JR Guieb
Tera Expert

Thanks Brad for your response.   Thank you for providing the link as it did help me understand reference attributes.   We do have the following attribute applied to the sys_user dictionary entry:



ref_ac_columns_search=true,ref_ac_order_by=name,ref_ac_columns=email,display_image=photo,ref_auto_completer=AJAXTableCompleter,iterativeDelete=true,text_index_translations



The issue I am having is that it doesn't show the email address in Service Portal.   I have attached a screen shot of how it looks like in Service Portal


find_real_file.png



The following attachment is how it looks like on the regular side of ServiceNow


find_real_file.png


Brad Tilton
ServiceNow Employee
ServiceNow Employee

Ahh ok. I haven't run into the issue where Service Portal doesn't work with reference attributes yet.



So going back to your original ask, you want name to be a calculated field which concatenates the first name, last name, and email fields together?


Hi Brad,



That is correct i want the name to be a calculated field which concatenates the first name, last name, and email fields together in the Service Portal.



Is there a way to do this for the Service Portal?