Show incident number instead of sys_id

salu
Mega Guru

Hello,

I am using script include to create incident.

I want to show the message when incident is being created.

In the below code its showing the sys_id of the incident.Can some one help on this.

  gs.include("FormInfoHeader");

  var fi = new FormInfoHeader();

  var s = 'Thanks! Incident number ' + inc.sys_id.getDisplayValue() + ' has been created!.<br/>';

  fi.addMessage(s);

Thanks

saranya

1 ACCEPTED SOLUTION

marcguy
ServiceNow Employee
ServiceNow Employee

inc.number instead of inc.sys_id.getDisplayValue()



getDisplayValue should only be used if you are looking at a reference field and you want to return the DisplayValue instead of the sys_id of the referenced record, even if incident was a reference field in this occasion it would only be inc.getDisplayValue()


View solution in original post

8 REPLIES 8

marcguy
ServiceNow Employee
ServiceNow Employee

yes indeed, the href should be completely hidden and just the number displayed, i.e.:



  1. var url= = '<a href=' + gs.getProperty("glide.servlet.uri") + '"/nav_to.do?uri=incident.do?sys_id=' + inc + '&sysparm_view=ess" target="blank">' + inc.number + '</a>';  


You may need to check the quotes are in the right place but that should be pretty much it.


Perfect.Thanks a ton


Thanks


Saranya


michal29
Mega Guru

Hello Saranya,



You can alternatively query for number from the incident table like having the sys_id



  gs.include("FormInfoHeader");


  var fi = new FormInfoHeader();



  var gi = new GlideRecord('incident');


  gi.get(inc.sys_id);



  var s = 'Thanks! Incident number ' + gi.number + ' has been created!.<br/>';


  fi.addMessage(s);


salu
Mega Guru

Awesome It worked.Thank you Michal and mguy



Thanks


Saranya