update document id field using glide record

salu
Mega Guru

Hello,

I want to update the document id field need to be updated.Can some one please help me with this?

Below code not working

var gr = new GlideRecord('new_call');

gr.initialize();

gr.caller = conversation.document.opened_by;

gr.opened_by = gs.getUserID();

gr.contact_type = "chat";

gr.insert();

var gr2 = new GlideRecord('chat_queue_entry');

gr2.addQuery('sys_id',id);

gr2.query();

if(gr2.next())

  {

  gs.log('Aug 7 ::: chat_queue_entry');

  gr2.source_table ='new_call';

  gr2.document_id=gr.sys_id;

  gr2.update();

  }

Thanks

Saranya

2 REPLIES 2

Karthik Reddy T
Kilo Sage

Use the below code and   try.



var gr = new GlideRecord('new_call');


gr.query();


//gr.initialize();// It will use for the creation of new record and not useful for uopdate so remove this.


gr.caller = conversation.document.opened_by;


gr.opened_by = gs.getUserID();


gr.contact_type = "chat";


//gr.insert();


gr.update();



var gr2 = new GlideRecord('chat_queue_entry');


gr2.addQuery('sys_id',id);


gr2.query();


if(gr2.next())


  {


  gs.log('Aug 7 ::: chat_queue_entry');


  gr2.source_table ='new_call';


  gr2.document_id=gr.sys_id;


  gr2.update();


  }


Karthik Reddy T.
ServiceNow Commnunity MVP -2018 class.

Hello Karthik,


I am want to insert call record and update document id in the chat queue entry table.



Thanks


Saranya