Quantcast
Channel: Microsoft Dynamics CRM
Viewing all articles
Browse latest Browse all 71679

Blog Post: USD – Start a Dialog from an Agent Script

$
0
0
In this post regarding Unified Service Desk (USD) for Microsoft Dynamics CRM 2016 I will look at how to start a CRM Dialog Process from an agent script in USD. I’m going to assume you understand how to create a CRM dialog and you have a basic understanding of USD and agent scripting! In my example I am going to use a simple dialog process to act as a wizard to create a new contact for an existing account. I am sure you could adapt this idea to support creating cases, opportunities or just about anything in CRM. I’ve shown an extract of my dialog below. I am not going to discuss it in detail. But it is pretty simply stuff, just a few pages and some prompt / response steps. Then a create contact command at the end. I am sure you can create a better dialog than me with a little time and effort! J Having created the dialog in CRM and tested it outside of USD, we then need to configure USD to use it. The steps are simple, Create a hosted control. Create some actions. Create an Agent Script answer. Add an event and action to the CRM Dialog hosted control. Step One – Create a Hosted Control. Like all good USD changes we need to start off by creating an object. (aka hosted control) Things to notice include that my USD component type is “CRM Dialog”, the hosting type is “IE Process”, it isn’t global and I have opted for MainPanel. You might want to play around with the display group. Other options that might work for could include “RightPanel” or “FloatingPanel”. (I tested FloatingPanel and liked it!) Step Two – Create Some Actions. Now we have our hosted control we are going to need two actions, the first calls the dialog. The second will refresh the contacts shown on the account tab. (This refresh is optional but useful, so I have included for reference really.) Let’s start by looking at the action to call the dialog. You can see below that I have created an action on my CRM Dialog hosted control. The action is “StartDialog” and then the data field defines the dialog I want to call. I have given details of each line in the data field below; Line Detail Name=Create Contact From Account This is the name I gave my dialog process in CRM. Entity=account This is the name of the entity the dialog runs against. Note: The notes suggested this wasn’t needed but when I initially tried without if my dialog didn’t load. So I included it anyway. id=[[account.Id]] This is the GUID of the account I want to run my dialog against. (i.e. the one I currently have loaded in my session in a hosted control called “Account”.) Notice the exact syntax! “ i d=” is all lowercase. I originally has “ I d=” as suggested in the help on the StartDialog action, but I found that didn’t work. My second action is optional and I will explain more about this in a second. Here my hosted control is “Account” and my action is “RunXrmCommand”. The my data field is defined as follows; function RunXrmCommand() { var subgrid = Xrm.Page.ui.controls.get("Contacts"); subgrid.refresh(); } RunXrmCommand(); So why do I need this? Well, to make the dialog work I don’t! But having created the new contact I immediately see it in the sub grid on the account form. The sub grid on my out of the box account form is called “Contacts”, so this command simply does a refresh on this grid without needing to reload the account form. Step Three – Create an Agent Script Answer I had an agent script on account already, so I simply needed to add an additional answer. You might need to create an agent script. Alternatively, this same concept could be applied to a toolbar button. I have shown my simple answer below. Also below you can see that I added the action we’ve just created to trigger the dialog Step Four – Add an event and action to the CRM Dialog hosted control For my refresh action, I wanted to refresh the details on the account form when the dialog closed. Out of the box I found that my CRM Dialog hosted control only had BrowserDocumentComplete and PopupRouted events. So the first thing I did was add a “ActiveClosed” event to my CRM Dialog hosted control. Having created my “ActiceClosed” event I added the action I created earlier. (As shown below) Finally, I Tested My Application Below you can see that I have my account open in a session, and in my agent script I have highlighted my newly created answer. Also notice that in contacts I only have one contact. Clicking “Create Contact(Dialog)” loaded my dialog in a USD tab. I then followed the wizard to create my new contact. I’ve shown the first [age of my wizard below; Having completed the wizard and closed my dialog the sub grid on the account for had been updated (automatically) as shown below. I created this test on dialogs as a proof of concept to understand how I might want to use them in the future. On the whole they worked well but I did find some limitations that are worth mentioning. Considerations / Limitations “Do you want to close this window?”, on clicking finish in the dialog I got a slightly annoying prompt! The window closed and the dialog worked correctly but I didn’t like the prompt. I tried the dialog in MainPanel and FloatingPanel and got the same results in both. I would have liked to have automatically loaded the newly created contact in a tab. Unfortunately, I didn’t find an east way to do this. I was hoping to see the results of the dialog available to me as data parameters in USD. (Ideally including the GUID for the new contact.) But I was out of luck! “Summary” and “Help” buttons are a standard feature of CRM dialogs. Both of these buttons open a new page. This causes a problem as the new page overwrites the dialog I am currently running. So not ideal. Despite these limitations I did like the user experience of running a dialog. I think linking dialogs to agent scripts could be very beneficial, imagine creating a case or opportunity in this manner. I hope this post has been useful and given you some ideas for your own solution. J Filed under: USD - Configuration Tagged: crm2016 , Microsoft Dynamics CRM , Unified Service Desk , USD

Viewing all articles
Browse latest Browse all 71679

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>