AXForum  
Вернуться   AXForum > Microsoft Dynamics CRM > Dynamics CRM: Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 23.08.2011, 12:11   #1  
Blog bot is offline
Blog bot
Участник
 
25,643 / 848 (80) +++++++
Регистрация: 28.10.2006
Gareth Tucker: Quick Create Contact from the Phone Call Form
Источник: http://gtcrm.wordpress.com/2011/08/2...one-call-form/
==============

Here’s a solution I’ve mocked up to speed up call handling times in a particular Call Centre scenario. 

Here we have Microsoft Dynamics CRM 2011 deployed into a Call Centre where our CSR’s are tasked with processing inbound calls.   The CRM system has been integrated to the telephony system such that when the caller can be matched to a CRM Contact record that Contact record pops for the user.  

But when the caller can’t be matched we want the CRM Phone Call form to pop for the user instead and we want to give the user a minimal-click solution that allows them to both record the Phone Call and the Contact.   Here’s what I came up with:



The telephony integration takes care of popping this form and provides us with the phone number of the caller.  It also populates the subject field for us as well.

If the CSR’s conversation with the caller indicates they should be in CRM (suggesting that the number they have called in from is new/different) then the CSR can use the out-of-the-box Sender field to search for the caller.

If the caller is new to us though the user can simply complete these steps to quickly create the Contact and link the Phone Call to the new Contact record:

1. The CSR clicks into the Title field in the Quick Create New Contact section of the form and populates:



Note: As soon as the CSR populates one of the fields in this section all the fields in the section become mandatory.

2. The CSR tabs out of the first field and then populates the second, and then the third:



3. The user tabs out of the Last Name field and custom code (jscript) is triggered. 

The code detects that all 3 mandatory fields have now been populated.  The jscript collects the field values from the form and then executes a REST call to create a new Contact based on those values.  On success, the code then updates the Sender field to reflect the Contact that was created and then disables the Quick Create fields:



For the user, the back end processing is invisible.  They simply followed an intuitive process. 

A little bit of jscript used in an supported (upgrade friendly) manner has allowed us to streamline the process by removing 6 clicks and one form load.   In a Call Centre environment this is gold.  

Here’s the jscript behind this.  The OnLoad function needs to be attached to the form’s OnLoad event.  The NewContact function needs to be attached to the OnChange event of the Title, First Name and Last Name fields.  The CreateContact function does the heavy lifting.

// Set lookup value of a field

function SetLookupValue(fieldName, id, name, entityType) {

if (fieldName != null) {

var lookupValue = new Array();

lookupValue[0] = new Object();

lookupValue[0].id = id;

lookupValue[0].name = name;

lookupValue[0].entityType = entityType;

Xrm.Page.getAttribute(fieldName).setValue(lookupValue);

}

}

 

function DisableFields() {

Xrm.Page.ui.controls.get("new_title").setDisabled(true);

Xrm.Page.ui.controls.get("new_firstname").setDisabled(true);

Xrm.Page.ui.controls.get("new_lastname").setDisabled(true);

Xrm.Page.ui.controls.get("phonenumber").setDisabled(true);

//Xrm.Page.ui.controls.get("new_phonetype").setDisabled(true);

}

 

function MakeFieldsMandatory() {

Xrm.Page.data.entity.attributes.get("new_title").setRequiredLevel("required");

Xrm.Page.data.entity.attributes.get("new_firstname").setRequiredLevel("required");

Xrm.Page.data.entity.attributes.get("new_lastname").setRequiredLevel("required");

Xrm.Page.data.entity.attributes.get("phonenumber").setRequiredLevel("required");

//Xrm.Page.data.entity.attributes.get("new_phonetype").setRequiredLevel("required");

}

 

function MakeFieldsNonMandatory() {

Xrm.Page.data.entity.attributes.get("new_title").setRequiredLevel("none");

Xrm.Page.data.entity.attributes.get("new_firstname").setRequiredLevel("none");

Xrm.Page.data.entity.attributes.get("new_lastname").setRequiredLevel("none");

Xrm.Page.data.entity.attributes.get("phonenumber").setRequiredLevel("none");

//Xrm.Page.data.entity.attributes.get("new_phonetype").setRequiredLevel("none");

}

 

function OnLoad() {

if (Xrm.Page.ui.getFormType() == 1) {

Xrm.Page.getAttribute("subject").setValue("Inbound phone call");

Xrm.Page.getAttribute("phonenumber").setValue("+65 9784 5862");

}

else if (Xrm.Page.ui.getFormType() != 1) {

DisableFields();

}

}

 

function NewContact() {

if (Xrm.Page.getAttribute("new_title").getValue() == null &&

Xrm.Page.getAttribute("new_firstname").getValue() == null &&

Xrm.Page.getAttribute("new_lastname").getValue() == null &&

Xrm.Page.getAttribute("phonenumber").getValue() == null) {

MakeFieldsNonMandatory();

}

else if (Xrm.Page.getAttribute("new_title").getValue() != null &&

Xrm.Page.getAttribute("new_firstname").getValue() != null &&

Xrm.Page.getAttribute("new_lastname").getValue() != null &&

Xrm.Page.getAttribute("phonenumber").getValue() != null &&

Xrm.Page.data.entity.attributes.get("from").getValue() == null) {

CreateContact();

DisableFields();

}

else {

MakeFieldsMandatory();

//Xrm.Page.ui.controls.get("from").setVisible(false);

}

}

 

function CreateContact() {

// Get the CRM URL

var serverUrl = Xrm.Page.context.getServerUrl();

 

// Cater for URL differences between on premise and online

if (serverUrl.match(/\/$/)) {

serverUrl = serverUrl.substring(0, serverUrl.length - 1);

}



// Specify the ODATA end point (this is the same for all CRM 2011 implementations)

var ODATA_ENDPOINT = "/XRMServices/2011/OrganizationData.svc";

 

// Specify the ODATA entity collection

var ODATA_EntityCollection = "/ContactSet";

 

// Define an object for the CRM record you want created

var CRMObject = new Object();

 

// Define attribute values for the CRM object

CRMObject.FirstName = Xrm.Page.getAttribute("new_firstname").getValue();

CRMObject.LastName = Xrm.Page.getAttribute("new_lastname").getValue();

CRMObject.Salutation = Xrm.Page.getAttribute("new_title").getValue();

CRMObject.Telephone1 = Xrm.Page.getAttribute("phonenumber").getValue();

 

//Parse the entity object into JSON

var jsonEntity = window.JSON.stringify(CRMObject);

 

//Asynchronous AJAX function to Create a CRM record using OData

$.ajax({

type: "POST",

contentType: "application/json; charset=utf-8",

datatype: "json",

url: serverUrl + ODATA_ENDPOINT + ODATA_EntityCollection,

data: jsonEntity,

beforeSend: function (XMLHttpRequest) {

//Specifying this header ensures that the results will be returned as JSON.

XMLHttpRequest.setRequestHeader("Accept", "application/json");

},

success: function (data, textStatus, XmlHttpRequest) {

//This function will trigger asynchronously if the Retrieve was successful

//alert("ajax call successful");

var NewCRMRecordCreated = data["d"];

var FullName = Xrm.Page.getAttribute("new_firstname").getValue() + " " + Xrm.Page.getAttribute("new_lastname").getValue();

SetLookupValue("from", NewCRMRecordCreated.ContactId, FullName, "contact");

},

error: function (XmlHttpRequest, textStatus, errorThrown) {

//This function will trigger asynchronously if the Retrieve returned an error

alert("ajax call failed");

}

});

}

 
You will need to upload the json and jquery libraries as web resources and reference in the On Load event along with the OnLoad function:



A CRM solution file containing these web resources and the changes to the Phone Call form are available for download here.







Источник: http://gtcrm.wordpress.com/2011/08/2...one-call-form/
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
Gareth Tucker: Building a Microsoft CRM 2011 VM – A Quick Checklist Blog bot Dynamics CRM: Blogs 0 03.08.2011 09:11
Microsoft Dynamics CRM Team Blog: Creating Custom Charts ~ Phone Call Duration Blog bot Dynamics CRM: Blogs 0 22.06.2011 01:13
emeadaxsupport: Possibilities to create Memory Dumps from crashing processes Blog bot DAX Blogs 0 12.05.2010 19:05
CRM DE LA CREME! Some more useful javascripts for MS CRM Blog bot Dynamics CRM: Blogs 0 04.05.2010 11:05
Khue Trinh: AX 2009 Quality Management - Quality Control Blog bot DAX Blogs 1 04.07.2008 16:01

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 19:40.