how can i copy any value to the work notes

shivaadapa
Tera Expert

Hi 

I want to insert one table number as reference to everyone. i am adding number to the work notes in the incident but i am unable to see anything in the worknotes. can i insert anything in the work notes by using script.
i used "incident.work_notes = ''TRE0001432";
But it is not populating this value.

3 REPLIES 3

Harish KM
Kilo Patron
Kilo Patron

Hi @shivaadapa there is a error in your script

"incident.work_notes = ''TRE0001432";

assuming your BR is on before update on incident table, it should be

current.work_notes = "TRE0001432";

Regards
Harish

Mark Manders
Mega Patron

Can you share your entire script, if the solution Harish provided doesn't work? 


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

tharun_kumar_m
Mega Guru

Hi Shivaadapa,

 

To insert a value to all the new records, you can create a onload client script and add the below line.

 

g_form.setValue("work_notes","TRE0001432");

To insert a value to all the old records, you can run a background script or fix-script and add the below code.

 

var gr = new GlideRecord("incident");
gr.addEncodedQuery("number!=INC0000001^ORnumber=NULL"); //to select all the records you can filter out only one record and copy the query from the breadcrumbs
gr.setLimit(2000); //you can execute the script in batch to avoid and performance issue.
gr.query();
while(gr.hasNext()){
gr.work_notes = "TRE0001432";
//gr.autoSysFields(false); if you don't want to update the fields like created, updated, created by, updated by
//gr.setWorkflow(false); // if you don't want any business rule to run due to this update to the record
gr.update();
}

 

If you have specific question regarding your error, please share your code so that we can find what went wrong.

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumbs up.

 

Best regards,

Tharun Kumar