Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

getDisplayValue is failing on string field

kuttti
Kilo Guru

Hello Everyone,

 

is something wrong with my script :

 

var visa ;
var g = new GlideRecord('sn_hr_core_profile');
g.addQuery('number=HRP0153690');
g.query();
if (g.next){
visa = g.getDisplayValue('u_employment_status');
gs.print("Print Visa value "+ visa);
}

 

Struck with simple query. Any help please ?

 

 

1 ACCEPTED SOLUTION

Mike_R
Kilo Patron
Kilo Patron

String fields do not have display values. Use getValue instead

visa = g.getValue('u_employment_status');

 

also in line 5, you are missing ()

g.next()

View solution in original post

5 REPLIES 5

Gunjan Kiratkar
Kilo Patron
Kilo Patron

Hi @kuttti ,

Use below script :-

var visa ;
var g = new GlideRecord('sn_hr_core_profile');
g.addEncodedQuery('number=HRP0153690');
g.query();
if (g.next()){
visa = g.getDisplayValue('u_employment_status');
gs.print("Print Visa value "+ visa);
}

Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy