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

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 03.04.2012, 10:11   #1  
Blog bot is offline
Blog bot
Участник
 
25,475 / 846 (79) +++++++
Регистрация: 28.10.2006
Gareth Tucker: Using a Dialog for Lead Conversion in CRM 2011
Источник: http://gtcrm.wordpress.com/2012/04/0...n-in-crm-2011/
==============

Microsoft have supplied a Lead Qualification screen where you can qualify or disqualify a Lead and chose what records you want created:



However, this screen sits outside CRM’s supported extensibility model and sometimes fails to meet requirements. When you hit this scenario you can attempt an unsupported customisation to the screen, you can build a replacement screen, you can use form fields and plug-ins to manage the requirement or you can use a Dialog.  In this post I will demonstrate the Dialog solution and provide some guidance on how you can improve the user experience.

Here’s my scenario.  I have Leads for both existing Customers (Contacts) and for non-customers.  I want users to be able to qualify or disqualify leads.  When they qualify them I want the system to create an Opportunity against a Contact record.  For non-customer Leads, the Contact record should be auto-created.

In this scenario the out-of-the-box screen has these limitations:
  • The user can choose to have a new Account created (I never want this)
  • The user can chose to have a new Contact created, even when the Lead references an existing Contact (we could end up with duplicates)
  • The user can accidentally chose to not have an Opportunity created
  • The user has to reselect the Contact on this form if they wish to associate the Opportunity to an existing Contact (despite the Contact being referenced on the Lead)
Ok, so let’s jump to the solution so you can see whether you like this approach.   I have added a Button to the Lead form’s ribbon menu which pops a Dialog:



If the user selects “Convert Lead” an Opportunity is created, the Lead status is updated and the Lead form is refreshed.  If the Lead referenced an existing Contact then the Opportunity will be attached to that Contact, otherwise a new Contact is created.  

If the user select “Disqualify Lead” the Dialog will prompt them for a reason and then update and close the Lead and refresh the Lead form.

The advantage with this approach is it is a more controlled user experience.  We are not exposing the user to options we don’t want them to select and not asking them to perform any double keying. 

Here’s how I configured this…

 

The Dialog

 

The Dialog is quite simple.  It has 2 pages.  The 1st page you see in the screenshot above.  It asks a question and captures the response.   You’ll see from the Dialog definition below that I then have a condition statement and only proceed to the 2nd page if the user chose the  “Disqualify” option on the 1st page:



Next, the Dialog needs to take action.  

For Disqualified Leads, the Dialog updates the Status of the Lead based on the Disqualify Reason captured:



For Qualified Leads, the Dialog checks whether the Lead references an existing customer and then either just creates an Opportunity record or creates a Contact and an Opportunity, before finally closing the Lead:



 

The Button

 

I added the Ribbon button using the VisualRibbonEditor available on CodePlex.  I copied the icon path and display rule from the out-of-the-box Qualify button.  I call a jscript function in a web resource.  I seemed to hit a limitation of the Ribbon editor in that I couldn’t reference multiple jscript libraries.  So I defined most of the button using the editor and then exported the Lead entity out in its own Solution file and edited the customization.xml directly.   Here’s the Action definition for the button:


My logic sits inside the LaunchDialog web resource and function.  However, that function needed to reference some other jscript libraries so I have specified those libraries in my Ribbon Action definition (with just NaN specified to provide a value for FunctionName). 

[Turned out I didn’t need these libraries in the end, you can ignore those first lines] 

I needed to pass the Lead record’s GUID to my function so you will see I added a CrmParameter to my definition as well.  “PrimaryItemIds” will give you the GUID of the current record.

 

The Jscript

 

Here’s my LaunchDialog function that the button calls.  There’s also a supporting function which just ensures the Dialog launches centred on screen:

function LaunchDialog(sLeadID) { //var DialogGUID = GetConfigValue("ConvertLeadDialogGUID"); var DialogGUID = "128CEEDC-2763-4FA9-AB89-35BBB7D5517D"; //var serverUrl = Xrm.Page.context.getServerUrl(); var serverUrl = "https://avanademarchdemo.crm5.dynamics.com/"; serverUrl = serverUrl + "cs/dialog/rundialog.aspx?DialogId=" + "{" + DialogGUID + "}" + "&EntityName=lead&ObjectId=" + sLeadID; PopupCenter(serverUrl, "mywindow", 400, 400); window.location.reload(true);}function PopupCenter(pageURL, title, w, h) { var left = (screen.width / 2) - (w / 2); var top = (screen.height / 2) - (h / 2); var targetWin = window.showModalDialog(pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left);}
 

I built this scenario for a demo and will now need to admit to a bit of hardcoding.  You can ignore the lines that are commented out, they represent failed efforts to avoid the hardcoding.  I ran out of time to resolve my issues there.  I think my issue was with accessing the CRM context from a jscript function called by a ribbon button, the normal xrm.Page.context didn’t seem to work for me.  Maybe I needed to use GetGlobalContext.  Hopefully someone reading this will explain that and I can come back and edit this post with the answer. 

Anyway, this function receives the Lead record’s GUID as a parameter (thanks to the ribbon definition) and combines that with the CRM Server URL and the GUID of the Dialog definition and then pops that URL.  It does use window.showModalDialog() and window.location.reload(true) to refresh the Lead form when the Dialog closes.

That’s it, I hope someone finds this useful.

GT.




Источник: http://gtcrm.wordpress.com/2012/04/0...n-in-crm-2011/
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
crminthefield: Podcast and Overview: Microsoft Dynamics CRM 2011 Update Rollup 7 Blog bot Dynamics CRM: Blogs 0 27.03.2012 02:11
Gareth Tucker: Installing the Customer Care Accelerator (CCA) for CRM 2011 Blog bot Dynamics CRM: Blogs 3 23.12.2011 09:16
crminthefield: Podcast and Overview: Microsoft Dynamics CRM 2011 Update Rollup 4 Blog bot Dynamics CRM: Blogs 0 24.09.2011 01:16
Microsoft Dynamics CRM Team Blog: Microsoft Dynamics CRM 2011 ~ Online Test Drive Guide Blog bot Dynamics CRM: Blogs 0 05.08.2011 20:13
Gareth Tucker: Getting Started with CRM 2011 Online Fetch XML Reporting Blog bot Dynamics CRM: Blogs 0 19.05.2011 23:13

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

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

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 21:00.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.