Anyone who reads my blog will hopefully know that I like answering questions about Unified Service Desk for Microsoft Dynamics CRM.
This time the question was “How do I create a toolbar button that will allow me to create a new contact and open in a session?”.
I’m going to make a few assumptions here;
- That you already have a hosted control to hold contacts.
- That you have already created session lines to open contacts in sessions.
- That you have a toolbar already working but need to add a button to create a contact.
Step One – Create an action.
First of all, we are going to need an action to open a new page for a contact. There a couple of approaches I could have taken to this but I decided to simply open a new CRM page. This action to do this looked like the one shown below.
Notice that the hosted control is my global manager and the action is “New_CRM_Page”. Then in the data field I have added the name of the entity I want to open. In this case “LogicalName=contact” will do the trick. But you could adapt this concept to create other entities such as account, phone call etc.
Step Two – Create a toolbar button that calls the action.
I next added a toolbar button to call this action, I added mine to my main toolbar.
The detail of my button looked like this;
Button text will show in my toolbar, and the tooltip will show if I hover over the option. The show tab setting of contact is because it is the contact tab I want to position on if this button is clicked.
My order of 1000 is simply to position the button within my toolbar.
And finally I added the action I just created.
Step Three – Create a Window Navigation Rule
At this point it is worth testing your application, it may already work! In which case skip this step.
The reason it might work is a rule is likely to already exist that will start a session for contacts. If it doesn’t you’ll need to create one. The rule that opened the session for my contact looked like this;
Some things to note / understand about this rule.
- The order is 300 because I have some other rules I want to be evaluated first. It is important to understand the way window navigation rules are evaluated. Each rule is considered in order, the first rule that matches the currently opening tab will be triggered. Any subsequent rules that also match will be ignored! If no rule is found, then USD will attempt to follow the default behaviour which will be to load the entity in the current tab.
- Notice my rule has no from field. This means if this rule is reach regardless of what hosted control triggered the popup this rule will be considered.
- Route type, Popup. This is significant as you can only create sessions from a popup. Which is find in this situation as our new CRM page action is going to popup a new page.
- Destination is tab, as we want to load the contact page into a tab.
- Action is “Create Session”, as we want a new session.
- Target tab and show tan are both set to “contact”. (Which I’ve assumed already exists!)
- Finally, I set hide navigation bar to yes, simply because I like to restrict navigation in sessions. This is optional!
Below you can see that in my USD application I now have a NEW CONTACT button in my main toolbar. Clicking this opens a new session containing a blank contact.
Hopefully these details will have answered the question I was asked. J