Personalized Community is here!
Quickly customize your community to find the content you seek.
Have questions on moving to the cloud? Visit the Dynamics 365 Migration Community today! Microsoft’s extensive network of Dynamics AX and Dynamics CRM experts can help.
2021 Release Wave 2Discover the latest updates and new features releasing from October 2021 through March 2022.
2021 release wave 2 plan
The FastTrack program is designed to help you accelerate your Dynamics 365 deployment with confidence.
FastTrack Community | FastTrack Program | Finance and Operations TechTalks | Customer Engagement TechTalks | Upcoming TechTalks | All TechTalks
Unified Service Desk (USD) for Dynamics 365 has two actions which until now I hadn’t used. Translate and DetectLanguage. What are these and what do they do?
In this post, I will explain these actions and show you a working example.
The Translate action provides on demand translation of text data using Azure Translation Services. Meaning we can translate a data parameter from any language to any language. Additionally, the DetectLanguage parameter provides the capability to determine the language of any block of text.
Below you will find a video that shows how I have used these actions within my USD solution to translate the body of any from English into another language. Or from English into any language.
Before I explain how this functionality was created, let me explain a little detail about these actions. These details will be based on the information you can find on Microsoft’s site, here. But I will add additional snippets of information that I’ve discovered. (With a little help from my friends!)
Enables you to perform language translations using Microsoft Translator.
The Translate and DetectLanguage actions are UII Actions of Global Manager.
Some valid examples:
value=$Escaped(“my stringnew line\\\”my text\\\””)
You may find it useful to review how replacement parameters work, see details here or here.
If this is blank, the system will attempt to detect the language of the specified value to be translated before translating.
For a list of valid language values, see Translator Language Codes.
If this option is blank that USD will look for an option called Azure_ClientId
For information about registering with Azure, https://datamarket.azure.com/developer/applications/
You can create a free trial which will work for development purposes. But this has limited functionality. For production use you will require an Azure subscription.
If this option is blank that USD will look for an option called Azure_ClientSecret
The translated value is displayed under the $Return replacement parameter.
Enables you to return the language of a block of text using Microsoft Translator.
The language value is displayed under the $Return replacement parameter.
Before you can use these actions some setup will be required.
Firstly, you will need to obtain a client ID and client secret for Microsoft Azure translation services. Using this link …. https://datamarket.azure.com/developer/applications/
You can obtain an Azure trial that will “work” for development purposes. But it will have a limitation that you can only complete one translation every 10 minutes. I have been told that this restriction is removed with a fully paid Azure subscription. I haven’t tested that! It would be great if the first person who tries these actions with a paid subscription could comment on this post to confirm this is correct.
Next you will need to make an alteration to one of USDs configuration files. UnifiedServiceDesk.exe.config
You will find this in the program directory of our Unified Service Desk client. Typically, this will be “Program Files/Microsoft Dynamics CRM USD/USD”
To edit this XML configuration file, you may need to copy to your desktop and open using any editor. (NotePad will do!)
You will need to insert a service binding to connect with Microsoft Translation Service. The code for this is below;
Below you can see that I have added this code into my config file.
In the following notes I will describe the steps I took to create the solution shown in my video.
I am going to assume that you can already open a CRM entity in a session and you have some functionality to open an email.
The steps involved are;
Step One – Create options
You should have a Client ID and Client Secret for the Azure translation service, now you could enter these on each of your Translate or DetectLanguage actions. However, I felt creating them as options was a more elegant approach. So in Unified Service Desk settings I opened the “Options” option and create two new ones.
I’ve shown my options below. You’ll need to create “Azure_ClientId” and “Azure_ClientSecret”. And enter appropriate values.
Step Two – Create Translate action
Next we need an action that will actually do our translation.
Some things to note ….
This will be significant when we add this action into the toolbar!
In particular, notice the approach I have taken to value, I found this method of using $Escaped coped with any formatting I added into the email. Including the formatting used on my email signature.
You will also notice that I have used a couple of values from my context for the from and to languages. We will see how these get set in a second!
Step Three – Create DetectLanguage action
The next action I needed was a DetectLanguage action. In my example I use this when converting an email from any “unknown” language into English. I am essentially automatically detecting the from language.
To be honest I have used this action just for demonstration purposes! As it is valid to omit from fromlanguage value from your Translate action.
Notice that I have used different syntax for my value field. Again I have simply done this to show a variation on how to set the value to be examined / translated.
Notice that I have no other parameters! I don’t need to set a clientID or clientSecret.
Step Four – Create “RunXrmCommand” action
Next we have a RunXrmCommand! Why?
The name of the CRM Page hosted control that holds my email activity.
Pay attention to the “]$]” in my replacement parameter. I found the $ was needed and the translation didn’t correctly apply if missed!
Step Five – Create “Copy To Context” actions
Next I created several actions to copy “from” AND “to” languages into my context. Essentially I always need two values in the context. One if “TranslateFromLanguage” and “TranslateToLanguage”.
CRM Global Manager – Copy To Context (To French)
CRM Global Manager – Copy To Context (To German)
CRM Global Manager – Copy To Context (To English)
Next I created one final Copy To Context action, this one was for my detected from language.
So this time I am copying the results in $Return from my DetectLanguage action.
Step Six – Create a toolbar and add actions
Ok, so now we have all the building blocks for this solution. They come together on a toolbar.
I’d already got a navigation toolbar on my email tab, so I simply added my translate button. My button looked like this.
In my example this simply made the button the last one.
This condition will hide the button until the email has been saved, as the email description will not be in the context until the email is saved.
FYI: A refinement to my approach would be to get the contents of the email description using a RunXrmCommand. As then you could skip having to save the email.
Next I used the toolbar buttons option available in the navigation.
My buttons were as follows;
Let’s look at the Email – Translate Other first. The button is simple enough, as shown below.
Now I created two more toolbar buttons. (Again, using the toolbar button in navigation.) One button was for translating into French and one for German.
They were almost identical, so let’s just look at the French one. As you can see below I simply gave the toolbar button a name and then added the actions we created earlier. For this button I added
Obviously from German button was about the same except I used the “CRM Global Manager – Copy To Context (To German)” action instead.
Finally, I created my button to translate an email from any language into English. Again it was simple. I just gave it a button text of “To English” and added some actions.
I hope this post has been useful, I think this is really cook feature. I look forward to hearing how people get on with this and keen to hear from someone who tries this with a paid Azure subscription. (Unlike me!)
Business Applications communities