Resolve Primary Key to value on a record

EB7
Giga Contributor

I have two tables in ServiceNow that has company information and Contact information.

Company table:

Company Key

Company name

Company Address

1

Example Company 1

123 Sample Drive, City, ST 12345

2

Example Company 2

124 Sample Drive, City, ST 12345

3

Example Company 3

125 Sample Drive, City, ST 12345

 

Contact/User Table:

Contact key

Name

Contact Address

Company Key

11

John Smith

Xyz address

2

12

Adam Abel

Abc address

3

13

Rice Rich

Cde address

1

14

Nick Jay

Fgh address

2

 

Question is, how can I have Company name returned on a Contact/User form instead of Company key?

I have Oracle DB administration background and this is approached differently as I have direct access to the DB, but not the case in ServiceNow. Any suggestions will greatly be appreciated.

 

Thanks,

EB

1 ACCEPTED SOLUTION

EB7
Giga Contributor

Thanks,

 

I'm still on the initial loading of the data into ServiceNow. At this point that field is empty and I want it to load automatically from the transform. 

I have solved this issue by adding this script to the transform map:

answer = (function transformEntry(source) {

var companyID = "";

// Get company record using manufacturer seq number
if(source.u_company_key){
var mfr = new GlideRecord("u_manufacturer");
mfr.addQuery("u_company_key", source.u_company_key);
mfr.query();
if(mfr.next()){
companyID = mfr.getValue('u_company_name');
}
}

return companyID;

})(source);

View solution in original post

30 REPLIES 30

Brent Sutton
Mega Sage

Hi EB,

This shouldn't be a problem. Just use a Reference qualifier dictionary entry for the company information on the user table. This will display the company name and contain the sys_id of the company record as the values.

Let me know if this answered your question.

Brent

P.S. If my suggestion helped then please mark as helpful and/or correct so other community members can benefit from this information. 

EB7
Giga Contributor

Hi Brent,

Thanks for you response.

I still don't know how to display company name on the user form instead of company key.

 

find_real_file.png

Hi EB,

If you are just wanting to add a "Company" field to the user then there is already one available OOTB.

Instructions:

Right-Click on Header in User form >> Configure >> Form Layout

find_real_file.png

Select "Company" >> Add >> Save

find_real_file.png

Result:

find_real_file.png

 

If you need to create a Company dictionary entry from scratch then the Reference Qualifier configuration should look something like this:

find_real_file.png

Let me know if this worked for you.

Brent

P.S. If my suggestion helped then please mark as helpful and/or correct so other community members can benefit from this information. 

EB7
Giga Contributor

Hi Brent,

 

Thanks for your detailed response. However, we have our own set of tables and real customer data to be used in ServiceNow and not OOTB.

find_real_file.png

Here's what I have so far. I'd like it to return company name instead of sys_id for the reference table record. 

Seems like I would have to implement a BEFORE business rule script to accomplish this.

 

Thanks,

-EB