Adding the callers phone number to a link to call on click

Moedeb
Tera Guru

I want to be able to add a link next to the caller field on for example the Incident form, so when someone clicks on it the phone call will auto launch in our softphone.

I have already proven that if I have a link like this:

<a href="tel:5550080148">Call us at 555-008-0148</a>



The softphone will launch and try to call the number given, so what I'm looking for is how to auto populate the current callers phone number into the link eg:

<a href="tel:[current.sys_user.phone]">Call us at 555-008-0148</a>



Ideas?

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Moedeb 

you should create UI macro and then associate it to the caller_id field

Steps below:

1) UI Macro

Name- show_phone_link

HTML:

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">

	<g:evaluate var="jvar_guid" expression="gs.generateGUID(this);" />
	<j:set var="jvar_n" value="show_incidents_${jvar_guid}:${ref}"/>
	<g:reference_decoration id="${jvar_n}" field="${ref}" 
							onclick="showRelatedList('${ref}'); "
							title="${gs.getMessage('Call phone')}" image="images/icons/tasks.gifx" icon="icon-phone"/>

	<div id="myDiv"></div>

	<script>
		function showRelatedList(reference) {
		var phone = g_form.getReference('caller_id').phone;
		var url = 'tel:' + phone;
		var mydiv = document.getElementById("myDiv");
		var aTag = document.createElement('a');
		aTag.setAttribute('href',url);
		aTag.innerText = "Call us at 555-008-0148";
		mydiv.appendChild(aTag);
		}
	</script>


</j:jelly>

2) update the dictionary as below for caller_id field

in the attributes section add this

To call UI Macro:-ref_contributions=show_phone_link

find_real_file.png

I have used Assigned to Field for example to show the Icon and link:

It shows the Phone icon

When user clicks on it it shows the link

find_real_file.png

Regards
Ankur

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

View solution in original post

16 REPLIES 16

Hi,

Seems strange

Regards
Ankur

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

@Ankur Bawiskar 

Yes very and like I said it's doing it in my instance as well.