Microsoft Dynamics CRM 2011

Microsoft Dynamics CRM 2011
Showing posts with label Prompt. Show all posts
Showing posts with label Prompt. Show all posts

Tuesday, October 15, 2013

Step-By-Step How to open a Dialog from Client Side using Javascript

by Carmel Schvartzman
  1. In this walkthrough we will learn how to open a Dialog automatically from Client Side, using Javascript and a Web Resource, in Dynamics CRM 2011. A Web Resource is just a virtual file containing html, jscript, css, a picture or Silverlight , stored in the CRM database, and identified by a unique URL. After its creation, a Web Resource can be used in several CRM Forms, enhancing its functionality and appeareance. In our example, we will use a javascript Web Resource to launch a Dialog when an  CRM Form opens:

  2. First, we'll need a javascript code inside a Web Resource. Open the Web Resources:
  3. ... and create a New Web Resource:
  4. Give it a Display Name with a "_" to make the Web Resource appear at the top of the Web Resources list, and set the Type to script:
  5. Open the Text Editor and type the javascript function that will open the Dialog:

    The first parameter represents the CRM context, and the second will be the ID of the CRM Dialog we want to launch from the form.

  6. Let's stop the creation of the Web Resource for now, and go to the form of the entity you want to open the dialog from:
  7. To relate our Web Resource to the form, open the Form Properties:
  8. Add the  Web Resource to the Form Libraries:

  9. Find and open the Web Resource we just created:
  10. Next, add it as the Event Handler script that will run on a "OnLoad" event:
  11. The next step is to set what will be the function that will be called. Be careful to type exactly the same name you saved when you created the Web Resource:

    Also, pass the execution context as the function's first parameter.
  12. Now we have a little problem: the second parameter must be the ID of the Dialog we want to open. Where we can obtain the GUID of the Dialog? Well, that's a bit tricky. Go to the Dialog you want to launch:
  13. Open it, and click "Copy a Link" from the Actions menu:

    That will copy to the clipboard a URL containing the GUID of the Dialog.
  14. Go back to the Event Handler , and paste it to the parameters text box:
  15. You can see a URL and an "ID" in it: this is the GUID of the Dialog:
  16. So erase everything else , and close the GUID with quotes:
  17. Save the form and Publish it. Now we have the parameters we need . Get back to the Web Resource, and type the following code to get the Organization's server URL:
  18. Next, we need to determine the Entity Name and the ID of the Record represented by the CRM Form, so type the following code:
  19. Now we build the URL of the window that will open the dialog. Start with the server:
  20. ...  and link the Entity Name and ID to the URL:
  21. Finally , type the javascript code that opens the window dialog:
  22. And we're done...  Let's see how it works: open some Contact:
  23. ...  And you'll see that the selected CRM 2011 Dialog launchs automatically when the Form opens:






    That's all...Enjoy Dynamics CRM!!!


    כתב: כרמל שוורצמן


Monday, October 14, 2013

Step-By-Step How to create a Dialog in CRM 2011


by Carmel Schvartzman

  1. In this walkthrough we will learn How to create a Dialog  in Dynamics CRM 2011. A CRM 2011 Dialog can automate processes, force bussiness rules,  and even guide the users through everyday tasks. 
  2. We'll automate a part of the creation of a new Contact, using a custom Dialog. 
  3. Suppose in our firm we want a new Contact belonging to certain Customer, to have not just a Bussiness phone, but also we need it to include a Mobile and Home numbers.
  4. In order to attain that, we'll create a Dialog which will lead the user to save a new Contact fast and comfortably, but constraining to type those phone numbers . If they're not typed, we will CRM to copy the Bussiness phone number to both Mobile and Home fields.
  5. Let's state that the Contacts whose Parent Customer is "Rick Deckard", will be required to state not only bussiness phone number, but also their Mobile and Home phones.
  6. In Customize the System, go to Processes:
  7. And Create a new Process:

  8. The Entity will  be Contact, and the Category "Dialog":

  9. State that the Dialog will run On Demand, and Add a new Step:

  10. The step will Check a CONDITION:
  11. On the dialog that opens, select "Parent Customer":

  12. The "account" property of the Parent Customer, meaning the Account object...

  13. ... must equal...

  14. ...the "Rick Deckard" Account:

  15. Check that you established the correct conditions:

  16. Next, IF this condition is TRUE, we want a Page to open (is important that you click and focus the correct AREA beneath the condition, to include this step UNDER THE SCOPE of the former step, and not as a step per se):
  17. Enter a description for the step:


    And under the scope of THIS Page, add a new "Prompt and Response" step:
  18. The Page will prompt to the user to enter both Mobile and Home phone numbers:


  19. Now, we'll add a checking to see whether the user did that:

  20. The CONDITION will use the current Contact entity:
  21. ...and its "Mobile Phone" field:

  22. ...and will check whether it contains data:

  23. This is the CONDITION ready to be saved:

  24. Inside the scope of this condition, we'll add a new Page containing a Prompt:
  25. The prompt will state to the user that because she/he didn't enter the numbers, therefore CRM proceeds to clone the Bussiness number:
  26. Next, and again inside the SCOPE OF THE CONDITION, we need to UPDATE our Contact to copy the numbers: so add a step to Update the Record:
  27. In the Contact form that opens, click on the "Home Phone" to focus:
  28. And select the Business Phone" from the Contact on the Form Assistant:
  29. You'll see that the Business Phone will be attached to the "Home Phone" field:

  30. Do exactly the same for the "Mobile Phone" field:
  31. Next, close and take a look at the final cut of the Dialog:
  32. Now Save and ACTIVATE the dialog:

  33. Now let's see how it works. Create a New Contact and enter some data in it. Remember to set the Parent Customer to "Rick Deckard", in order to fulfill the first CONDITION of the dialog:

  34. For the first test, let's see what happens if the user typed indeed the three phone numbers:
  35. Start the Dialog:
  36. ... selecting the dialog we created:

  37. ...and you'll see the first prompt appearing:

  38. ... and the "Next" leads the user right to the end of the dialog:

    Why is that? Because the user typed the three phone numbers, and the second condition doesn't apply.
  39. Now let's do the test without the phone numbers:
  40. The first prompt fires:
  41. But the user hasn't got the numbers, therefore the second IF condition applies:
  42. Save and close the Contact:
  43. ..and when reopening it, you'll see the phone values had been copied automatically by CRM 2011:







    That's all...Enjoy Dynamics CRM



    כתב: כרמל שוורצמן