Chat Incident Auto Populate

ctsmith
Mega Sage

When an incident is created from chat, it does not auto populate the first name, middle name, and last name (it only populates the caller_id) of an incident as it normally would when an incident is created by other means aside from a chat session.   It seems g_chat is limited in what it can do.   Is there a way to add the first/middle/last names from the chat action for creating an incident from chat?

Thanks!

Chris

1 ACCEPTED SOLUTION

This was able to pull out the necessary information just by querying on the sys_user table:



var chatinfo = new GlideRecord ("sys_user");


  chatinfo.get(g_chat.getChatQueueUser());




g_chat.fire(LiveEvents.WINDOW_CREATE_DOCUMENT,


  'incident',


  {


      caller_id : g_chat.getChatQueueUser(),


      short_description: g_chat.getProperty('short_description'),


      u_reported_source: 'Chat',


  state: '2',


  incident_state: '0',


  u_email_address: chatinfo.email,


  u_phone_number: chatinfo.phone,


  u_incident_location: chatinfo.location


}


);


View solution in original post

18 REPLIES 18

Travers M
Mega Guru

If you look at your chat actions and choose "create Incident from Chat" you can edit that to populate fields.   We left the oob version alone and made a new one to tinker with.     I remember running into all sorts of hang ups with it though.



For the OnClick Action Script, this info was added



var theChatID = [];


var theQIDString = g_chat.getProperty(LiveGUI.WIN_PROP_QUEUE_JID);


theChatID = theQIDString.split('.');




var grChat = new GlideRecord("chat_queue");


var theQueue = theChatQueue();


g_chat.fire(LiveEvents.WINDOW_CREATE_DOCUMENT,


  'incident',


  {


      caller_id : g_chat.getChatQueueUser(),


      short_description: g_chat.getProperty('short_description'),


  contact_type: 'Chat',


  assignment_group: theQueue.u_inc_assignment_group


  }


);



function theChatQueue(){


grChat.addQuery("sys_id",theChatID[1]);


grChat.query();


if (grChat.next()) {


return grChat;


}



That populates the requester, Short description, contact type and assignment group for the incident.   You could add lines that would populate other fields accordingly.


Thanks, Travers.   I saw a thread where a similar script was written to access the assignment group off a chat to create an incident.   But theQueue doesn't have any reference to the customer's name.   Plus, any of the other liveGui chat commands Chat helpful API (g_chat,Live events methods) don't seem to offer a way to access the first and last names of the customer--only the displayed caller_id.   I should also add I'm quite new to this, so I may be missing something right in front of me 😕



Thanks again!


Chris


I may be way off on this, but I tried to pull in email and had no luck:



var theChatID = [];


var theQIDString = g_chat.getProperty(LiveGUI.WIN_PROP_CHAT_QUEUE_USER);


theChatID = theQIDString.split('.');


var grChat = new GlideRecord('User');


var theQueue = theChatQueue();




g_chat.fire(LiveEvents.WINDOW_CREATE_DOCUMENT,


  'incident',


  {


      caller_id : g_chat.getChatQueueUser(),


      short_description: g_chat.getProperty('short_description'),


      u_reported_source: 'Chat',


  state: '2',


  incident_state: '0',


  u_email_address: theQueue.email


}


);




function theChatQueue(){


grChat.addQuery("sys_id",theChatID[1]);


grChat.query();


if (grChat.next()) {


return grChat;


}


}



----------------------------------



I get the error:


Error running context menu action: TypeError: undefined is not an object (evaluating 'theQueue.email')


This was able to pull out the necessary information just by querying on the sys_user table:



var chatinfo = new GlideRecord ("sys_user");


  chatinfo.get(g_chat.getChatQueueUser());




g_chat.fire(LiveEvents.WINDOW_CREATE_DOCUMENT,


  'incident',


  {


      caller_id : g_chat.getChatQueueUser(),


      short_description: g_chat.getProperty('short_description'),


      u_reported_source: 'Chat',


  state: '2',


  incident_state: '0',


  u_email_address: chatinfo.email,


  u_phone_number: chatinfo.phone,


  u_incident_location: chatinfo.location


}


);