9. Dealing with incoming calls for new contact
Go to Client Script for “Contact” page.
Select [Client Scripts] menu to create new 2 scripts.
Create a script that will create a new contact (customer entry) for each call.
Fill information. Copy the following script and paste it at the [Script] field.
create-new-contact-client-scripts.js;
function onLoad() { //Populate the variables with the parameters passed in the URL var phone = getParameterValue('sysparm_phone'); if(phone){ g_form.setValue('customer_contact.phone',phone); } } function getParameterValue(name) { name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]"); var regexS = "[\\?&]" + name + "=([^&#]*)"; var regex = new RegExp(regexS); var results = regex.exec(top.location); if (results == null) { return ""; } else { return unescape(results[1]); } }
Create another script that uppdates call log for new customer. Copy the following script and paste it at the [Script] field.
update-call-log-client-scripts.js:
function onSubmit() { //Type appropriate comment here, and begin script below var phone = g_form.getValue('customer_contact.phone'); var data = { "phoneNumber": phone, "action": "updateCallLogForNewContact" }; var context = { "payload": data, "method": "openframe_communication" }; alert(' send event to openframe '+phone); CustomEvent.fireAll("openframe_request", context); alert(' processing '+phone); }