UI Action on custom table to create incident, need to return incident.number

Matthew Glenn
Kilo Sage

I have a custom table/form () with a UI Action that creates an incident whenever clicked. Neither the task nor incident tables are extended to this table. Everything regarding the incident creation works great. All fields are inserted into the incident and the incident is created. Only problem is, I'm unable to return the incident number that was created back to the form using 'g_form.addInfoMessage'

Using the code excerpt you see below, I get 'Incident [object Object] created.',



//creates incident and injects into Incident table
var incident = new GlideRecord('incident');
<SOME CODE THAT ISNT RELEVANT>
var sysID = incident.insert();
g_form.addInfoMessage("Incident " + incident + " created.");



If I change the addInfoMessage to the below, I receive 'Incident undefined created.'


g_form.addInfoMessage("Incident " + incident.number + " created.");



What simple thing am I missing here? Is the fact that I did not extend the task or incident table out causing this?

Any help is appreciated.

5 REPLIES 5

neetusingh
Giga Guru

Oh!! I took it reverse (creating a record on custom table from incident). Okay, I have tried it that you are looking for also and I am able to get the Incident number on my custom form/table without any heck.

I beleive that your UI Action is running at server side, Try with the below line to get the incident number :
gs.addInfoMessage("Incident " + incident.number + " created.");

If it doesn't work, then I would ask you to share your ui action's full code to get better understanding of what's going wrong.