How to get the value from sys_id in the client script?

Murthy JN1
Tera Contributor

Hi,

 I have an onLoad client script that displays the parent incident if we open a child. I am getting sys_id instead of the actual value. Please guide. 

This is the script:

function onLoad() {
if(g_form.parent_incident != '')
{ alert("This is hte parent of " +g_form.getValue('parent_incident'));  }}

Someone has taught me using GlideRecord is not a suggested practice in Clinet Scripts.  How to populate actual value instead of sys_id?

1 ACCEPTED SOLUTION

Raghu Ram Y
Kilo Sage

@Murthy JN 

Yes, it is not a best practice to use glide record on client script, so you can get the value by using client script it self..

Try the below On Load Client script.

function onLoad() {
var usr = g_form.getReference('giveparentfieldname',callBack);
 }
 function callBack(usr){
     alert(usr.number);
   }
} 

View solution in original post

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

what's your requirement?

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hitoshi Ozawa
Giga Sage
Giga Sage

Hi Murphy,

Parent incident may be viewed by putting "Parent Incident" field on the form.

  1. Open any Incident form or a New Incident
  2. Select Form Design
    find_real_file.png
  3. Drag & drop "Parent Incident" on to a form
    find_real_file.png
  4. Save the form
  5. Parent Incident can now be displayed by clicking on the magnifying glass next to the Parent Incident field.