We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

script is not working

chandan31
Tera Contributor

Hi All,

 

This script is not wokring and i am written in Human resource core scope:

 

var shrt_desc = current.short_description;
    var lastwords = shrt_desc.trim().split(/\s+/);
    var ab = lastwords[lastwords.length - 1];
    var cd= ab.toString();
  //  gs.info('test_123'+cd);
  var gr = new GlideRecord('sn_hr_core_profile');
         gr.addQuery('user_name',cd);
         gr.query();
         if(gr.next()){
         gs.info('test_123'+gr.user);
         }
 
 
info message giveing undefined.
 
 
Can anyone help me 
 
Thanks ,
Chandan 
1 REPLY 1

Not applicable

Hi @chandan31 

If //  gs.info('test_123'+cd); this line is giving you the desired output for variable cd, then you should check if you are using the correct field name in this line gs.info('test_123'+gr.user);

Check if the backend name of the field is "user".

 

Thanks