Email field not copying from Interaction to Case

ronyates
Tera Guru

When creating a case from an interaction I need to copy the email address to the case but it is not copying. 

 

Here is the code for the UI Action:

current.update();

var newRecord = new GlideRecord("sn_customerservice_chat");
newRecord.initialize();


if (!gs.nil(current.account))
    newRecord.setValue("account", current.getValue("account"));

if (!gs.nil(current.contact))
    newRecord.setValue("contact", current.getValue("contact"));

if (!gs.nil(current.consumer))
    newRecord.setValue("consumer", current.getValue("consumer"));


newRecord.setValue("short_description", 'Case created from Interaction -['+current.getValue('number')+']');
newRecord.setValue("description", current.getValue("transcript"));
newRecord.setValue("assignment_group", gs.getProperty('rebode_chat_assignment_group'));
newRecord.setValue("assigned_to", gs.getUserID());
newRecord.setValue("state", 10);
newRecord.setValue("u_contact_email", current.getValue('consumer.email'));

if (GlidePluginManager.isActive('com.snc.csm_proxy_contacts') && !gs.nil(current.opened_for) &&
    current.opened_for.sys_class_name == "sys_user" && new sn_csm_proxy_cont.ProxyContactHelper().isUserProxyContact(current.getValue("opened_for")))
    newRecord.setValue("internal_contact", current.getValue("opened_for"));

if (current.getValue('type') == 'phone')
    newRecord.setValue('contact_type', 'phone');
if (current.getValue('type') == 'chat')
    newRecord.setValue('contact_type', 'chat');


action.openGlideRecord(newRecord);

// Tracks number of "Create Case" clicks on the Interaction form via CSM Agent Workspace
var csmWorkspaceUAUtil = new sn_csm_workspace.CSMWorkspaceUAUtil();
csmWorkspaceUAUtil.createCaseClickInteraction();

intRelUtil = new global.InteractionRelationshipUtil();
if (intRelUtil.copyAttachments !== undefined)
	intRelUtil.copyAttachments(current, newRecord);

 This is the line of code that is not working: 

newRecord.setValue("u_contact_email", current.getValue('consumer.email')); 

Any help would be appreciated.

1 ACCEPTED SOLUTION

Chaitanya ILCR
Kilo Patron

Hi @ronyates ,

try this script

current.update();

var newRecord = new GlideRecord("sn_customerservice_chat");
newRecord.initialize();


if (!gs.nil(current.account))
    newRecord.setValue("account", current.getValue("account"));

if (!gs.nil(current.contact))
    newRecord.setValue("contact", current.getValue("contact"));

if (!gs.nil(current.consumer))
    newRecord.setValue("consumer", current.getValue("consumer"));


newRecord.setValue("short_description", 'Case created from Interaction -['+current.getValue('number')+']');
newRecord.setValue("description", current.getValue("transcript"));
newRecord.setValue("assignment_group", gs.getProperty('rebode_chat_assignment_group'));
newRecord.setValue("assigned_to", gs.getUserID());
newRecord.setValue("state", 10);
newRecord.setValue("u_contact_email", current.getElement('consumer.email'));

if (GlidePluginManager.isActive('com.snc.csm_proxy_contacts') && !gs.nil(current.opened_for) &&
    current.opened_for.sys_class_name == "sys_user" && new sn_csm_proxy_cont.ProxyContactHelper().isUserProxyContact(current.getValue("opened_for")))
    newRecord.setValue("internal_contact", current.getValue("opened_for"));

if (current.getValue('type') == 'phone')
    newRecord.setValue('contact_type', 'phone');
if (current.getValue('type') == 'chat')
    newRecord.setValue('contact_type', 'chat');


action.openGlideRecord(newRecord);

// Tracks number of "Create Case" clicks on the Interaction form via CSM Agent Workspace
var csmWorkspaceUAUtil = new sn_csm_workspace.CSMWorkspaceUAUtil();
csmWorkspaceUAUtil.createCaseClickInteraction();

intRelUtil = new global.InteractionRelationshipUtil();
if (intRelUtil.copyAttachments !== undefined)
	intRelUtil.copyAttachments(current, newRecord);

 

I have just changed getValue in this to getElement

newRecord.setValue("u_contact_email", current.getValue('consumer.email')); 

if that doesn't work use current.consumer.email

 

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

View solution in original post

2 REPLIES 2

Chaitanya ILCR
Kilo Patron

Hi @ronyates ,

try this script

current.update();

var newRecord = new GlideRecord("sn_customerservice_chat");
newRecord.initialize();


if (!gs.nil(current.account))
    newRecord.setValue("account", current.getValue("account"));

if (!gs.nil(current.contact))
    newRecord.setValue("contact", current.getValue("contact"));

if (!gs.nil(current.consumer))
    newRecord.setValue("consumer", current.getValue("consumer"));


newRecord.setValue("short_description", 'Case created from Interaction -['+current.getValue('number')+']');
newRecord.setValue("description", current.getValue("transcript"));
newRecord.setValue("assignment_group", gs.getProperty('rebode_chat_assignment_group'));
newRecord.setValue("assigned_to", gs.getUserID());
newRecord.setValue("state", 10);
newRecord.setValue("u_contact_email", current.getElement('consumer.email'));

if (GlidePluginManager.isActive('com.snc.csm_proxy_contacts') && !gs.nil(current.opened_for) &&
    current.opened_for.sys_class_name == "sys_user" && new sn_csm_proxy_cont.ProxyContactHelper().isUserProxyContact(current.getValue("opened_for")))
    newRecord.setValue("internal_contact", current.getValue("opened_for"));

if (current.getValue('type') == 'phone')
    newRecord.setValue('contact_type', 'phone');
if (current.getValue('type') == 'chat')
    newRecord.setValue('contact_type', 'chat');


action.openGlideRecord(newRecord);

// Tracks number of "Create Case" clicks on the Interaction form via CSM Agent Workspace
var csmWorkspaceUAUtil = new sn_csm_workspace.CSMWorkspaceUAUtil();
csmWorkspaceUAUtil.createCaseClickInteraction();

intRelUtil = new global.InteractionRelationshipUtil();
if (intRelUtil.copyAttachments !== undefined)
	intRelUtil.copyAttachments(current, newRecord);

 

I have just changed getValue in this to getElement

newRecord.setValue("u_contact_email", current.getValue('consumer.email')); 

if that doesn't work use current.consumer.email

 

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

Thank you! This worked.