I love it when I can answer questions about Unified Service Desk for Microsoft Dynamics CRM.
I was asked a question yesterday about refreshing the case form. The problem was …. if you refresh an existing case from a toolbar the case form correctly reloads. But if you create a new case and then try the same refresh it goes “wrong”. As a refresh in this situation would display a new case form when you really want it to redisplay the newly created case.
This potentially looked like quite a difficult problem but actually the answer is really easy. Here is how I solved this problem …..
As I describe my answer to this question I am going to assume you already have a contact or account opening in a session. And from this you can create new cases or open existing ones.
- Create an action (Refresh case)
- Create an action (Navigate Case)
- Create an action (Display Message)
- Create toolbar button to fresh my case form.
- Add actions to the Case’s RefreshRequested event.
Step One – Create an action (Refresh Case)
First of all, I will need an action to refresh my case form. Although strangely this is never going to actually be used! (This will make sense in a second.)
|Name||Case – Refresh|
Step Two – Create and action (Navigate Case)
Next we will need the action that will actually be used to fresh the case. When the refresh is clicked I am going to need to re-display the currently displayed case. When I open an existing case this action will mirror the refresh functionality. But when working with a new case it will refresh the newly opened case correctly.
|Name||Case – Navigate|
To explain, this url will display the case form. Notice that I have added the Incident.Id of the current case.
This condition will mean the action will only be fired if we have an incident loaded.
Step Three – Create an action (Display Message)
Next I needed to decide what to do if I didn’t have a incident.Id. As my navigate action wouldn’t work. I decided the best approach might be a friendly message to the user.
Tip: An alternative approach might be to not present the toolbar refresh button until an Incident.Id is available!
|Name||CRM Global Manager – Display Message (Save Case)|
|Hosted Control||CRM global Manager|
|Data||text=Please save case first!
This condition will mean the action will only be fired if I don’t have an incident. Which will happen if the user has started to create a new case but hasn’t yet saved it.
Step Four – Create toolbar button to refresh my case form.
You might have this already!
I am assuming you have a toolbar on the case form already.
I had an image of the refresh icon loaded as a web resource, so I simply used that. If you don’t have an image an alternative approach would be to set button text to “Refresh”.
As my refresh button was my 4th button. Other numbers are available!!!
|Actions||I added the action I created in step one here. (Case – Refresh)|
Step Five – Add actions to RefreshRequested Event
As you have seen I am going to fire the refresh action as normal but that I will alter the RefreshRequested event for my incident form to actually use the other two actions I created. Below you can see I have added the two actions to my RefreshRequested action.
Finally, I tested my changes to prove they worked. If I click my refresh icon on a newly created but not saved case I display the message below.
But if I click refresh after saving the case that case will now be correctly refreshed. When prior to my changes a new case form would have been displayed.
I did find a problem with this! I have found that the RefreshRequested event does not behave as expected! Firing a refresh action does trigger the RefreshRequested event. But if the user presses F5 the event isn’t triggered. I suspect this might be a product issue! As I this the event should always be triggered. I am using USD 220.127.116.116, hopefully in future versions this issue is resolved.
I hope this answers the question I was asked. J