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

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 13.06.2011, 12:11   #1  
Blog bot is offline
Blog bot
Участник
 
25,475 / 846 (79) +++++++
Регистрация: 28.10.2006
furnemont: How-to series: Send SMS messages from CRM 2011 (part 2)
Источник: http://www.furnemont.eu/2011/05/how-...m-2011-part-2/
==============

In the first part (see part 1), I explained how a SMS could be better to communicate with your customers and contacts, since it is instantly dispatched on the cell phone.

In this part, I’ll deal with customizing the CRM as to enable this kind of communication.



How I’m doing it

Since we are dealing with a new activity, we are going to create a new activity entity; this entity will be responsible for sending the SMS messages to our contacts so we need a button to really do the action of ‘sending’ the message.

What I’ve devised is a simple method to send the message: once the ‘send’ button is clicked, a small JavaScript function changes the state of a check box on the message form then saves the message; once the message has been saved, a C# plugin is called which verifies the status of the check box and then constructs a message to send to Clickatell’s gateway.

That’s it! Pretty easy right?

In the remaining of this post, I’ll deal with:

  • The creation of the new custom entity
  • The implementation of the JavaScript function
  • The customization of the custom entity main form’s ribbon
Create a new activity type entity

The first thing to do is to create a new custom entity that will allow us to send SMS messages to our customers; of course this entity must be a new activity type, since we want to track down every single message sent to them in our communication history.

So here are the steps to follow:

  1. In Microsoft CRM, go to your new ‘SMSMessaging’ solution (see part 1), click on the ‘New’ button and select ‘Entity’ in the sub-menu
  2. In the new screen, enter the following information
    • Display Name: SMS Message
    • Plural Name: SMS Messages
    • Name: XXX_smsmessage (or whatever you want)
    • Tick the ‘Define as an activity entity’ check box and make sure ‘Display in Activity Menus’ is checked as well
    • The rest is up to you


    • Save your new entity
  3. Now it’s time to add or modify some fields that will help us store the SMS message information such as: when was it sent, to which customer and which phone number, what is the message status, etc.
    Field Display Name
    Custom

    Type Comment RegardingObjectID Contact
    No

    Lookup When creating a new SMS message from an account or contact, only this field is set by default! Subject Text Message
    No

    Text The text sent in the SMS message XXX_phonenumber Phone Number
    Yes

    Text The contact’s phone number (must be formatted properly) XXX_readytosend Ready to Send?
    Yes

    Bit Is the message ready to send or not (more on that later on)
  4. Customize the main form to something like this
  5. Add some cool icons and publish your customization and check to see if it looks good
Ok, we are done with the entity customization… now we need to create a small JavaScript function that will change the ‘Ready to send’ check box

Add a JavaScript function

Since we are going to use a C# plug-in for sending the message, we need something to ‘tell’ it to create the message and send it properly: this will be done thanks to our ‘Ready to send’ check box and JavaScript code below:

function SendSMS()

{

if (Xrm.Page.getAttribute("xxx_readytosend").getValue() == false)

{

Xrm.Page.getControl("xxx_readytosend").setDisabled(false);

Xrm.Page.getAttribute("xxx_readytosend").setValue(true);

Xrm.Page.getControl("xxx_readytosend").setDisabled(true);

Xrm.Page.data.entity.save("saveandclose");

}

else

{

alert("SMS message already delivered for sending!");

}

}
This code must be included in a JS file and in the solution:

  1. In your solution, click on the ‘New’ button and select ‘Web Resource’ in the sub-menu
  2. In the new screen, enter the following information
    • Name: XXX_sendsms
    • Display Name: Send SMS JavaScript
    • Description: whatever you like
    • Type: Script (JScript)
    • You can either paste your JavaScript code by using the ‘Text Editor’ button or upload your JS file (my choice here)
  3. Save and close the screen to upload the file to Microsoft CRM
  4. That’s it, your JavaScript has been packaged!
The last thing we need to do is to add something that’ll help us send the SMS message: this will be possible thanks to a custom button in the new entity’s ribbon, that will call our JavaScript function.

Customize the ribbon

The customization of the entity’s ribbon must be done manually in the customization file, which must be exported by using the solution export functionality:



  • Once the solution has been exported, you’ll find a single ZIP file where is enclosed several XML files; the one we are interested in is the ‘customizations.xml’ file:
  • Open this file in your favorite text editor and look for the following node




    ofusms_smsmessage

    10000











  • In the ‘RibbonDiffXml’ section, you have to (just copy the code below and you’re done ) :

      • Add a custom action containing the new ‘Send’ button

      • Add a command definition containing a call to your JavaScript send function

      • Add a rule definition that enables the button when creating or updating an active SMS message

1:

2:

3:

4:

5:

6:

7:

8:

9:

10:

11:

12:

13:

14:

15:

16:

17:

18:

19:

20:

21:

22:

23:

24:

25:

26:

27:

28:

29:

30:

31:

32:

33:

34:

35:

36:

37:

38:

39:

40:

41:

42:
Let me explain what this code does:

  • Line 3: Defines where a custom button (for example) will be positioned in the default ribbon
  • Line 5: This line defines the custom button, with all its properties (the button text, the JavaScript command, the icons, etc.)
  • Line 8 & 9: These 2 lines are used to hide a particular element in the ribbon (in these cases the ‘Save as complete’ & ‘Deactivate’ buttons)
  • Line 15: This line defines the command that has been set in the button properties (see line 5, ‘Command’)
  • Line 17: This line defines when the command can be used, it is a reference to the line 29
  • Line 21: This line defines which JavaScript function is called in which web resource when the button is clicked
  • Line 29: This is the rule definition for the custom button (same as saying ‘when is the button enabled?’)
Why did I use an ‘OrRule’ in my ‘EnableRules’ section? Well, a CRM form can’t be in ‘Create’ mode and in ‘Edit’ mode at the same time so you need to specify that the button is enabled either in ‘Create’ or ‘Existing’ (‘Edit’) mode

Make sure you include your modified customization file in a newZIP file and import it back in your CRM, publish everything and you should see something like this in your SMS message form ribbon:



This is it for this pretty long post, I’ll take you on the plugin journey in the next part so stay tuned for the big final!






Источник: http://www.furnemont.eu/2011/05/how-...m-2011-part-2/
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
furnemont: How-to series: Send SMS messages from CRM 2011 (part 3) Blog bot Dynamics CRM: Blogs 0 13.06.2011 12:11
Microsoft Dynamics CRM Team Blog: Demystifying the Recurring Appointment series expansion in Microsoft Dynamics CRM 2011 Blog bot Dynamics CRM: Blogs 0 09.12.2010 02:13
CRM DE LA CREME! Configuring Microsoft Dynamics CRM 4.0 for Internet-facing deployment Blog bot Dynamics CRM: Blogs 0 18.08.2009 11:05
Microsoft Dynamics CRM Team Blog: List Web Part for Microsoft Dynamics CRM 4.0 Deployment Scenarios Blog bot Dynamics CRM: Blogs 0 30.01.2009 22:05
Microsoft Dynamics CRM Team Blog: List Web Part for Microsoft Dynamics CRM 4.0: Understanding Connections Blog bot Dynamics CRM: Blogs 0 20.01.2009 02:07

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

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

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