The CreatorCon Call for Content is officially open! Get started here.

How to copy worknotes from interaction to Incident table on Agent Workspace

Meenal Gharat
Tera Guru

Hi All,

how can we copy worknotes from Interaction to Incident on agent workspace?

I tried editing with below UI Action yet no luck, can someone help me with this.

if(current.update()){
var inc = new GlideRecord("incident");
inc.initialize();
inc.caller_id = current.opened_for;
inc.short_description = current.short_description;
var worknotes = inc.work_notes.getJournalEntry(1);
//inc.work_notes = current.work_notes;
worknotes = current.work_notes;
action.openGlideRecord(inc);
}

 

Thank you.

Regards,

Meenal

 

1 ACCEPTED SOLUTION

Audrey Deruere
Mega Expert

Hello,

 

For those who wants the solution :

- Create a business rules on the table "interaction_related_record", before insert with order of 400 and copy this code :

(First part has been taken from another OOB business rules, it's because BR run twice on insert ....)

var existingRelationship = new GlideRecord("interaction_related_record");
existingRelationship.addQuery("interaction", current.interaction);
existingRelationship.addQuery("document_id", current.document_id);
existingRelationship.setLimit(1);
existingRelationship.query();

if (existingRelationship.next()) {
current.setAbortAction(true);
}else{
var grTask = new GlideRecord(current.document_table);
grTask.get(current.document_id);

grTask.work_notes = current.interaction.work_notes.getJournalEntry(-1);
grTask.update();

var attachment = new GlideSysAttachment();
attachment.copy('interaction', current.interaction.sys_id, current.document_table, current.document_id);
}

 

 

 

View solution in original post

22 REPLIES 22

Kieran Anson
Kilo Patron

Hi Meenal,

Edit the 'Create Incident' UI Action on the interaction to the following

if(current.update()){
	var inc = new GlideRecord("incident");
	inc.initialize();
	inc.caller_id = current.opened_for;
	inc.short_description = current.short_description;
	inc.work_notes = current.getJournalEntry(1); // Copy only latest work note. Change to getJournalEntry(-1) to copy over all work notes.
	action.openGlideRecord(inc);
}

Hi Kieran,

Thank you for your response.

I tried the above code yet no luck. 

Regards,

Meenal

Ok Meenal,

What functionality are you expecting? This is what I see when using the above script.

 

Chaitanya Maddu
Tera Contributor

I tried below and it worked for me..

if(current.update()){
var inc = new GlideRecord("incident");
inc.initialize();
inc.caller_id = current.opened_for;
inc.short_description = current.short_description;

---New lines, need to insert record once needed fields are copied and then work on work notes and file attachments----
//record inserted to incident table
inc.insert();
//copying worknotes and additional comments from IMS to INC
inc.work_notes = current.work_notes.getJournalEntry(-1);
//copying attachments from IMS to INC
GlideSysAttachment.copy('interaction', current.sys_id, 'incident', inc.sys_id);


inc.update();
action.openGlideRecord(inc);

}