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

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()


Hello mguy



How can keep this incident number as link in which view needs to be ess


marcguy
ServiceNow Employee
ServiceNow Employee

Put the url into the message, something along these lines:



var url = gs.getProperty("glide.servlet.uri") + 'nav_to.do?uri=incident.do?sys_id='+inc.sys_id+'%26sysparm_view=ess'; //Here the ess view is used


Hello Mguy,


  In the created I want to show the incident number as a link.Here the URL is coming correctly.



Any way to show this url to as Incident number




gs.include("FormInfoHeader");


  var fi = new FormInfoHeader();


  var number1=inc.number;


  var url = gs.getProperty("glide.servlet.uri") + '/bdc?id=form&table=incident&sys_id='+inc.sys_id+'&view=ess';



  var s = 'Thanks! Incident number ' + url+ ' has been created! The Support Team will address the issue and contact you if needed. You will need this ticket number for tracking purposes.<br/>';


  fi.addMessage(s);



  return inc.sys_id;




  },