copy chat to work note

Puneet4418
Tera Contributor

Hello Experts,

I have created a connect action to create a request through chat and copy the chat conversation to work notes.

Currently, for every chat conversation a specific journal entry is getting created in RITM worknote.

My requirement is to copy all chat conversation to a single entry in the work note of RITM.

 

Please help me to update the script.

 

Puneet4418_0-1715875265520.png

 

3 REPLIES 3

Sandeep Rajput
Tera Patron
Tera Patron

@Puneet4418 Please update your script as follows and check if it works.

 

 

var id = conversation.document.sys_id;
var gr = new GlideRecord('live_group_profile');
gr.addQuery('document', id);
gr.query();
gs.log("GR Count " + gr.getRowCount(), "HelpCreateReq");
if (gr.next()) {
    var reqItem = new GlideRecord('sc_req_item');
    reqItem.addQuery('request', req.sys_id);
    reqItem.query();
    gs.log("reqItem Count " + reqItem.getRowCount(), "HelpCreateReq");
    if (reqItem.next()) {
        var msg = new GlideRecord('live_message');
        var encQry = "group=" + gr.getValue('sys_id') + "profile.name!=ITHelpNow Chat";
        msg.addEncodedQuery(encQry);
        msg.setLimit(5);
        msg.query();
        gs.log("msg Count " + msg.getRowCount(), "HelpCreateReq");
        var message = '';
        while (msg.next()) { // copying the conversation notes to RITM comments
            gs.log("msg: " + msg.getValue('message').toString(), "HelpCreateReq");
            message = message+'\n' + msg.getValue('message').toString();
        }
        reqItem.work_notes =message;
       reqItem.update();
    }
}

 

Hi @Sandeep Rajput ,

 

It is copying all the chat in the last entry of the work note. However, Still creating entry for every chat conversation line.

mention below is an example. 1,2 & 3 are the chat conversations.

 

work note - 1,2,3

work note - 1,2

work note - 1

@Puneet4418 Could you please post some screenshot highlighting the issue.