CRM 2011 Dialogs–A couple of gotchas

A couple of things to look out for as you start writing Dialogs:

  1. If your Dialog has branching logic make sure you don’t use the Responses from those branches in any later actions after the branching as those Response values will not be available in those scenarios when the user branches the other way, and CRM doesn’t like that.   To get around this make use of Variables within your Dialog.  Initialise a Variable at the start of your Dialog, update it within your branch and then you can happily refer to the Variable later in the script.
  2. Beware of placing actions such as creating records and sending emails in amongst Pages of your Dialog, they’re better placed at the end of your script firing only after the user has clicked Finish in the Dialog.  Reason for this is the Dialog UI happily allows users to navigate backwards and forwards within the Dialog.  If you have a record creating firing between pages 4 and 5 of your script that record creation will happen not only the first time the user progresses to page 5 but if they hit previous, go back to page 4 and then progress on to page 5 again then yeap you guessed it you will get another record created.

HTH Smile

Gareth

Advertisements

10 thoughts on “CRM 2011 Dialogs–A couple of gotchas

  1. Pingback: CRM 2011 – Using Dialogs and Dialog gotchas « Hosk's Dynamic CRM 2011 Blog

  2. Pingback: CRM 2011 – Using Dialogs and Dialog gotchas - Hosk's Dynamic CRM 2011 Blog - CRM Technical Blogs - Microsoft Dynamics Community

  3. acraigx

    2 more for your list…

    1. Cannot use global option sets. I have a dialog where I am prompting for the customer’s state field. That’s 50 options I need to recreate. What a drag… As an alternative, I was hoping to be able to create a query against the Option Set entity but it isn’t made available.

    2. If I prompt the user for the state and they neglect to fill it out (or similarly if you need to prompt the user for a value that may not be applicable for the record you are creating) the dialog places the first option set value in the created form’s state field. Weird…

    Reply
  4. Rodney

    How do you add actions at the end of the dialog so records are only created after user clicks finished? I tried creating two stages (the 2nd stage being at the end of the process with no pages, that creates the records), and both stages still get processed before the user clicks finish. If I add a Stop Dialog step before the 2nd stage, it doesn’t get triggered at all. So I’m confused on how one would achieve your 2nd gotcha in the above post. Any advice would be greatly appreciated.

    Reply
    1. Gareth Tucker Post author

      Hi, not sure there is a decent solution to this. My advice is to put your actions at the end of your dialog definition wheneever possible to minimise the issue. But, you can’t have dialog actions run after the Finish button. If you are launching the Dialog from a custom Ribbon button via jscript you can fire code on the Dialog window’s close, but then you would need to write your actions in jscript, not in the dialog. Something I saw in a demo recently was a Dialog where the last page before the Finish button page dispkayed back to the user hyperlinks of CRM records that were created by the Dialog. This is kind of cool, providing instant navigation options to the user. But it also makes it clear to the user that the records have been created by that point, and they would hopefully think twice before clicking the Back button. HTH.

      Reply
    1. Gareth Tucker Post author

      Creating a Quote record is simple enough from a Dialog, just like creating any record type. Quote Product creation however is not supported by the Dialog designer. You need to get a little bit creative, here’s some approaches: 1) Use a custom entity, create records in that entity from the Dialog and then use a Plug-in to create the Quote Product records based on the custom entity records. 2) Capture quote product details in the Dialog and populate into fields on the Quote record and then use a plugin to create the Quote Products records. 3) If you call the Dialog form from jscript you could ahve additional jscript fire on close of the Dialog form that creates the Quote Product records (tricky though, as you likely need data captured during the Dialog session). HTH 🙂

      Reply
  5. Simon Hetzel

    One way that I found works for number 2 is to put the action (and any feedback to the user re success/faliure) in a child dialog. Then link to the child dialog, as you said, at the end of the main dialog. When you link to a child dialog I found you can’t go back to the main dialog – so problem solved?

    Reply
  6. faesa

    Hi Gareth,
    The first stage of my dialog as a query listing all the contacts with the same email address (I have put this criteria in the FetchXML query directly).
    The query returns no value and shows this message “There are no records to display”.

    Do you know why the button Next is greyed out? And do you know a workaround for that?

    Many thanks 😉

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s