Adding work note with UI Action

thenckel
Mega Contributor

Using the UI Action of "Create Incident" I'm trying to add a script so that it will log the incident number into the work notes from

the previous incident.   I've tried all different scripts and nothing is working for me.   Here is the current script I've put in and nothing in the work notes.

current.work_notes.setJournalEntery('number');

Here is the full script in "Create Incident" UI action....

var inc = new GlideRecord("incident");

inc.company = current.company;

inc.location = current.location;

inc.caller_id = current.caller_id;

inc.u_affected_user = current.u_affected_user;

inc.u_phone = current.u_phone;

inc.contact_type = current.contact_type;

inc.short_description = current.short_description;

inc.description = current.description;

inc.category = current.category;

inc.subcategory = current.subcategory;

current.work_notes.setJournalEntery('number');

var sysID = inc.insert();

var mySysID = current.update();

gs.addInfoMessage("Incident " + inc.number + " created");

action.setRedirectURL(inc);

action.setReturnURL(current);

Any assistance would be appreciated.   Thanks.

1 ACCEPTED SOLUTION

I've got it working now, when creating a new incident off of an older incident I added this into my script;



inc.work_notes = ("Ref #" + current.number);



now its working the way I was expecting.   Thank you all for your assistance.



Here is the final code.



var inc = new GlideRecord("incident");


inc.company = current.company;


inc.location = current.location;


inc.caller_id = current.caller_id;


inc.u_affected_user = current.u_affected_user;


inc.u_phone = current.u_phone;


inc.contact_type = current.contact_type;


inc.short_description = current.short_description;


inc.description = current.description;


inc.category = current.category;


inc.subcategory = current.subcategory;



inc.work_notes = ("Ref #" + current.number);             //here is the new entry that puts the previous incident number into the new ticket



var sysID = inc.insert();



var mySysID = current.update();



gs.addInfoMessage("Incident " + inc.number + " created");


action.setRedirectURL(inc);


action.setReturnURL(current);


View solution in original post

5 REPLIES 5

Chuck Tomasi
Tera Patron

Hi Tom,



Have you tried a straight forward:



current.work_notes = 'number';



???


Yes, it still doesn't put the last incident number into the work notes.


Victor Ruiz
Tera Guru

Try:   current.work_notes.setJournalEntery(inc.getDisplayValue('number'));


I've got it working now, when creating a new incident off of an older incident I added this into my script;



inc.work_notes = ("Ref #" + current.number);



now its working the way I was expecting.   Thank you all for your assistance.



Here is the final code.



var inc = new GlideRecord("incident");


inc.company = current.company;


inc.location = current.location;


inc.caller_id = current.caller_id;


inc.u_affected_user = current.u_affected_user;


inc.u_phone = current.u_phone;


inc.contact_type = current.contact_type;


inc.short_description = current.short_description;


inc.description = current.description;


inc.category = current.category;


inc.subcategory = current.subcategory;



inc.work_notes = ("Ref #" + current.number);             //here is the new entry that puts the previous incident number into the new ticket



var sysID = inc.insert();



var mySysID = current.update();



gs.addInfoMessage("Incident " + inc.number + " created");


action.setRedirectURL(inc);


action.setReturnURL(current);