The location based on caller is not setting when incidents are created form Interactions

Kaustubh k
Tera Contributor

Hi All,

 

When ever a chat is live (interaction) and agent clicks on create incident the ticket an incident is  created from the agent workspace and populates the fields as mapped .

 

But the location of the caller not not getting set when the incident is created and is left out blank.

 

There is a onchange script which handles this reference on the incident form

 

function onChange(control, oldValue, newValue, isLoading) {
g_form.setReadOnly('location.country', true);
g_form.setReadOnly('location.u_region', true);
   if ((isLoading && !g_form.isNewRecord()) || (g_form.isLiveUpdating && g_form.isLiveUpdating()))
      return;
 
   if (newValue == '' || newValue == null) {
      g_form.setValue('location', '');
      return;
   }
   if (!g_form.hasField('location'))
      return;
   var caller = g_form.getReference('caller_id', setLocation);
}
 
function setLocation(caller) {
   if (caller)
       g_form.setValue('location', caller.location);
}
 
Please suggest for any changes here or changes needs to be done Agent workspace level.
 
Thanks
Karan
1 ACCEPTED SOLUTION

Tushar
Kilo Sage
Kilo Sage

Hi Karan,

 

 

 

function onChange(control, oldValue, newValue, isLoading) {
  g_form.setReadOnly('location.country', true);
  g_form.setReadOnly('location.u_region', true);

  if ((isLoading && !g_form.isNewRecord()) || (g_form.isLiveUpdating && g_form.isLiveUpdating()))
    return;

  if (newValue == '' || newValue == null) {
    g_form.setValue('location', '');
    return;
  }

  if (!g_form.hasField('location'))
    return;

  var caller = g_form.getReference('caller_id', setLocation);

  // If the incident is newly created and the caller is available, explicitly call setLocation function
  if (g_form.isNewRecord() && caller)
    setLocation(caller);
}

function setLocation(caller) {
  if (caller)
    g_form.setValue('location', caller.location);
}

 

Please, don't forget to mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!

Regards,
Tushar

View solution in original post

1 REPLY 1

Tushar
Kilo Sage
Kilo Sage

Hi Karan,

 

 

 

function onChange(control, oldValue, newValue, isLoading) {
  g_form.setReadOnly('location.country', true);
  g_form.setReadOnly('location.u_region', true);

  if ((isLoading && !g_form.isNewRecord()) || (g_form.isLiveUpdating && g_form.isLiveUpdating()))
    return;

  if (newValue == '' || newValue == null) {
    g_form.setValue('location', '');
    return;
  }

  if (!g_form.hasField('location'))
    return;

  var caller = g_form.getReference('caller_id', setLocation);

  // If the incident is newly created and the caller is available, explicitly call setLocation function
  if (g_form.isNewRecord() && caller)
    setLocation(caller);
}

function setLocation(caller) {
  if (caller)
    g_form.setValue('location', caller.location);
}

 

Please, don't forget to mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!

Regards,
Tushar