On change of caller field on incident form show UI Macro ?

Tejasr1
Tera Contributor

I have done Servicenow to Whatspp integration :

I have randomly chosen the Use case : I have created a UI macro and placed  beside the caller field of incident form.When anyone click on whatspp icon it redirect to selected  caller whatspp and send a incident details to him/her.
But I want to show whatspp icon on change of caller field.
Below is my code.
Can someone Please help me?

 

 

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<a><img src="whatsppicon.png" width="70%" height="70%" onclick="whatsppWindow('${ref}')"></img></a>
<script>
function whatsppWindow(reference)//incident.caller_id
{
 var demotext;
 var mob;
 var incSysid = g_form.getUniqueValue();
 alert(incSysid);
 var refVal= reference.split('.');
 var fieldName=refVal[1];
 var sysId=g_form.getValue(fieldName);//Get caller Sys_id
 var user=new GlideRecord('sys_user');
 if(user.get(sysId))
{
  mob=user.mobile_phone.toString();
}
var incident=new GlideRecord('incident');
if(incident.get(incSysid))
{
 demotext = "Hi " + user.first_name + ",\nYour Incident Number is: " + incident.number + '\nYour Issue Description is: ' + incident.short_description;
}

mob=mob.replace(/[^0-9]+/gi,'');
if(mob)
{
open('https://wa.me/'+mob+'?text='+encodeURIComponent(demotext),'_top');
}

}
</script>
</j:jelly>​

 

@Ankur Bawiskar

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Tejasr1 

let the icon be there always and anyhow based on what value is present in the field the same will be picked up in the UI macro

 

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

@Tejasr1 

let the icon be there always and anyhow based on what value is present in the field the same will be picked up in the UI macro

 

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Thanks for the Suggestion.

@Ankur Bawiskar 
Can you suggest me more use cases on servicenow to Whatspp integration?

Regards 
Tejas

@Tejasr1 

I haven't implemented it for any customer, so cannot share any.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader