Category Archives: D365 General
Creating Case in Dynamics 365 from Microsoft Social Engagement Posts
Introduction: This blog explains how to Create Case in Dynamics 365 from Microsoft Social Engagement Posts. Steps to be followed: Steps in Dynamics 365: Go to Settings –> Service Management –> Automatic Record Creation and Update Rule. Click on +NEW. Enter Name and Set the Source Type to Social Activity. Save the record Under Channel Properties section for additional properties select the search button and Create new record. Enter details. Save record Create Channel Properties Under Newly Created Channel Property Group. Enter Name and Data Type. Save record Add specify record creation and update details Enter Name and save the record. Under Condition, choose Select, and scroll to the bottom of the drop-down list to find Channel Properties under Local Values. Then, select userPreferredTargetEntity Equals incident. Under Action, select Add Step, and then select Create Record. Set the value to Case. If you want to set or change any field value you can do it by clicking on set properties and changing the fields accordingly. Save and close the record. Finally select Activate to activate the rule. Steps in Microsoft Social Engagement: Go to settings –>Automation Rule Click on + to create new automation rule. Enter Name. Filter according to your criteria. Click on + ADD NEW ACTION to add actions. Click on link to Dynamics 365. Select Instance and Entity. Click on Apply. You can also Assign this case to user from MSE. Click on Apply Click on ADD NEW ACTION Select Set label. Click on Apply. Record Details: Save the rule. Case in Dynamics 365:
Share Story :
Business Recommendation in D365 using Business Rule
Introduction: Business Recommended a cool feature in Business Rules which came out last year in D365 that can be used by simple configuration in Business Rules rather than writing JS code to achieve the same. Here’s how we do it – Setting Up Business Rule for Recommendation: Now, can you setup a Business Rule as below which can be shown on a certain condition Select Add Recommendation is a Business Rule condition is met. And then define the Recommendation you added to the condition Click Apply. Then, inside the Details of the Recommendation, we can set the value of the Price List which will take effect if the user selects Apply on the Recommendation. Seeing Recommendation work: Now as designed, Recommendation is supposed to show up when you select the Relationship Type as Customer. Recommendation is designed to not appear for other values of Relationship Type other than Customer. Recommendation would ask you to Apply the default Retail price list if you select Relationship Type as customer. Once you click on the blue ‘info’ icon on the field, a recommendation will pop-up asking if you want to apply a default price list for the same. On clicking Apply, the specified action will be performed. In this case, the Product Price List will be set. Pretty easier than writing code!
Share Story :
Paging in D365 Customer Engagement v9.0
Introduction: The Xrm.retrieveMultipleRecords method is used to retrieve a collection of records in Dynamics 365 Customer Engagement . In this blog we will demonstrate how we can use paging and fetch more than 5000+ records. In CRM when we fetch records using code we only get the first 5000 records, in some cases there are more than 5k records that need to be fetched, we can achieve this using paging. In this blog for the demonstration purpose, we will fetch 3 records per page so that we can see how the paging functionality works in D365 v9.0 Implementation: Step 1: The syntax is as shown below: Xrm.WebApi.retrieveMultipleRecords(entityLogicalName, options, maxPageSize).then(successCallback, errorCallback); Here the in options parameter we specify the query. In our example we will be fetching all the accounts in the system. In the maxPageSize parameter we specify the number of records to be returned per page. By default the value is 5000. In this example we set the maxPageSize as 3 which will return 3 records per page. As the total number of records being fetched are more than 3, the nextLink attribute is retuned with the link to fetch the next set of records. The value of the nextLink attribute returned is already encoded. Before we pass the link to fetch the next set of records we have to make sure to only set the query in the options parameter. We also store all the values returned in a separate variable so that it can be used later. Step 2: The code is shown below. The allaccounts variable will store all the accounts fetched at the end as we keep on concatenating the received results. Code: var query = “?$select=name”; var allaccounts = null; var scripting = { retrieveMultipleContacts() { var url = Xrm.Page.context.getClientUrl() + “/api/data/v9.0/accounts”; Xrm.WebApi.retrieveMultipleRecords(“account”, query, 3).then( function success(result) { var resultRetrieved = result; allaccounts = resultRetrieved.entities.concat(allaccounts); if (result.nextLink != undefined) { console.log(“Next page link: ” + result.nextLink); query = result.nextLink; var splitValue = query.split(url); query = splitValue[1]; scripting.retrieveMultipleContacts(); } }, function (error) { console.log(error.message); } ); } } Step 3: To test this out we can simply trigger this code to run on the change of form fields and while debugging we can check the values returned and stored in the allaccounts variable. Conclusion: The new D365 v9.0 Xrm.WebApi.retrieveMultipleRecords method simplifies the whole process of fetching records using paging.
Share Story :
Set up Dynamics 365 connection in Microsoft Social Engagement
Introduction: This blog explains how to Set up Dynamics 365 connection in Microsoft Social Engagement. Steps to be followed: Go to settings Under connections tab go to Microsoft Dynamics 365. Click in + to create connection and then click on Accept. Select the connection type. You can click on CHECK INSTANCES it will load the instances. Or you can enter the URL of the instance in Dynamics 365 instance URL box. Finally give name to your connection. If you want to make this as your default connection. click ON the set as default option. Save.Note: You can only connect to those instances who are in same office 365 tenant.
Share Story :
Calendar Rule Entity not supported in Power BI
In Power BI, Dynamics 365 is connected using its Web API i.e [organization URI]/api/data/v9.0 Dynamics 365 Web API does not support GET Request for calendarrule entity; because of which Power BI cannot retrieve calendar rule entity details. You can verify by browsing to the URL: [organization URI]/api/data/v9.0/calendarrules Please refer to the screen capture below for the error details in browser. Also, you will not be able to load the calendar rule entity in Power BI. Below screen capture displays an error received in Power BI.
Share Story :
Xrm.Device.pickFile in D365 v9.0
Introduction: In this blog we will be showing an example to attach the uploaded files to notes using the Xrm.Device.pickFile function in unified Interface in D365 v9.0 Implementation: Step 1: In this example we will create a button on the Contacts entity and we write a JavaScript function to trigger on button click. In Ribbon Workbench after creating a button we create a command as shown below and add the command on the button. Step 2: On clicking on the Upload button a dialog box opens and we can select the file we want, this file will then be attached in the notes section of the particular record. The code is shown below. The name of the Note created, name of the attachment can be changed as required by modifying the code. Code: var crmCustomization = { PickFile: function () { Xrm.Device.pickFile().then( function (result) { var dataRecieved = result; var Content = dataRecieved[0].fileContent; var FileSize = dataRecieved[0].fileSize; var FileName = dataRecieved[0].fileName; var MimeType = dataRecieved[0].mimeType; var recordId = Xrm.Page.data.entity._entityId.guid; crmCustomization.UploadToNotes(FileName, MimeType, Content, recordId); }, function (error) { alert(error.message); }); }, UploadToNotes: function (FileName, MimeType, Content, recordId) { var note = Object(); note[“notetext”] = “New Attachment” note[“subject”] = “Uploaded File”; note[“filename”] = FileName; note[“mimetype”] = MimeType; note[“objectid_contact@odata.bind”] = “/contacts(” + recordId + “)”; note[“documentbody”] = Content; $.ajax({ type: “POST”, contentType: “application/json; charset=utf-8”, datatype: “json”, url: Xrm.Page.context.getClientUrl() + “/api/data/v9.0/annotations”, async: true, data: JSON.stringify(note), beforeSend: function (XMLHttpRequest) { XMLHttpRequest.setRequestHeader(“Accept”, “application/json”); XMLHttpRequest.setRequestHeader(“OData-MaxVersion”, “4.0”); XMLHttpRequest.setRequestHeader(“OData-Version”, “4.0”); }, success: function (data, textStatus, XmlHttpRequest) { var result = data; alert(“File attached to Notes successfully”); }, error: function (XmlHttpRequest, textStatus, errorThrown) { Xrm.Utility.alertDialog(“Error: ” + textStatus + ” ” + errorThrown); } }); }, }; We can see after uploading the file the note is created with the attachment as shown below
Share Story :
How to Configure Alert Configuration in Microsoft Social Engagement
Introduction: This blog explains how to Configure Alert Configuration in Microsoft Social Engagement. Steps to be followed: Go to Message Center Click on + to create alert configuration. Enter the following details: Name: Give name to your alert. Alert Type: select the type of alert you want. Post alert/Trend alert Email recipients: Enter the email address of recipients to whom alert mail should go. Filters: Select filters to narrow the posts to the data set you want to work with. i.e. which posts will be received by recipients. Add Search Topic: You can also filter based on the following criteria. Example filtering based on source and Language: After configuring click on SAVE.Post alert in mail:
Share Story :
Create Approval Flow with D365 conection
Introduction: This blog explains how to Create Approval Flow using Microsoft Flows. Use Case: When work order is updated. (Trigger) Check condition: system status: – open-completed and approved: -NO If condition satisfied: – Check Total amount: – If amount is greater than 1000 approval mail will be sent to approver. if he approves: update the work order with system status value closed-posted. else do nothing. update the work order with system status value closed-posted. Else do nothing. Steps to be followed: Sign in to the Microsoft flow. https://flow.microsoft.com/en-us/ Go to My flows –> create from blank Select Dynamics 365 when a record is updated Select the Organization Name and Entity Name for which you want to create flow. Click on + New step –> Add a condition. So here I want my flow should run when system status is open-completed and approved is NO. (Add your own conditions). Condition:@and(equals(triggerBody()?[‘msdyn_systemstatus’], 690970003),equals(triggerBody()?[‘cf_approved’], false) ) Go to Yes. Click on …More –> add a conditionCondition is: Total amount is greater than 1000. Go to yes. Add Action. Select Approvals –> Start an approval action. Enter details.In Assigned to enter the email address of the approval. Go to No. configure for amount is not greater than 1000. Click on Add an action. –> select Dynamics 365 – update a record. Enter the details. Enter the details Record identifier: Enter the record identifier of Work Order from when a record is updated step. Set the system status value to: 690970004 Add condition in Yes and check the approval status. On Yes. Select Add an action à Dynamics 365 – Update a record Enter the detailsRecord identifier: Enter the record identifier of Work Order from when a record is updated step.Set the system status value to: 690970004 Complete Flow:
Share Story :
Download Doucument Templates using Console App
Dynamic 365 development services has a team of experts, D365 architects and developers who works closely in every step in the business while closely understanding the requirements and designing the right solution for the business according to the needs as far as development is concerned the development team has a set of experts and developers that coordinate closely with the client and by using standard microsoft development technologies like visual studio and TFS online a robust and concrete development process is strategised. After developing the application it is internally tested according to the business needs and submitted to microsoft in order to clarify any issues. After that the application is listed on the App Source. Introduction: In this blog we will be demonstrate how to download word document templates from D365 Customer Engagement and then import them to another environment. Often there are requirements to move document templates from one environment to another. But currently adding document templates to solutions is not supported. To overcome this we have created a console app which downloads the word document template. Implementation: Step 1: To download Document templates we have created a Console App and it requires the following details: Username Password Organization Service Endpoint Address GUID of the template word template to download The username and password are the basic details that we use to log in to https//:www.portal.office.com To get the Organization Service Endpoint Address, navigate to Settings > Customizations > Developer Resources and copy the address as shown in the image below. To get the GUID of the Template Navigate to Settings > Templates > Document templates and open the template you want to download and Click on the Pop Out option at the top right as shown below Then from the URL we can get the GUID of the record as shown Step 2: The code to download the document template is shown below. It downloads the Word template and stores it in the location specified in the code. Remember to change this location to the location on your PC. Note: Replace all the required values in the code according to your organization details. Code: using Microsoft.Xrm.Sdk; using Microsoft.Xrm.Sdk.Client; using System; using System.Net; using System.ServiceModel.Description; using System.Text; using Microsoft.Crm.Sdk.Messages; using Microsoft.Xrm.Sdk.Query; using System.IO; namespace DownloadDocumentTemplates { public class DocumentTemplateDownload { static IOrganizationService _service = null; static OrganizationServiceProxy _proxy = null; static void Main(string[] args) { ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; ConnectToCRM(“test@test.onmicrosoft.com”, “pass@1234”, “https://test.api.crm8.dynamics.com/XRMServices/2011/Organization.svc”); Guid userId = ((WhoAmIResponse)_service.Execute(new WhoAmIRequest())).UserId; if (userId != null) { Console.WriteLine(“Guid: ” + userId); //GUID of the document template String documentTemplateId = “094EEB2A-948C-E711-8112-70106FAA45E1”; GetDocumentTemplateContent(documentTemplateId); Console.ReadKey(); } } public static void ConnectToCRM(string _username, string _Password, string _OrgSOAPServiceUri) { try { ClientCredentials credentials = new ClientCredentials(); credentials.UserName.UserName = _username; credentials.UserName.Password = _Password; Uri serviceUri = new Uri(_OrgSOAPServiceUri); _proxy = new OrganizationServiceProxy(serviceUri, null, credentials, null); _proxy.EnableProxyTypes(); _service = (IOrganizationService)_proxy; } catch (Exception e) { Console.WriteLine(“Error while Connecting: ” + e.Message); } } public static void GetDocumentTemplateContent(string documentTemplateId) { EntityCollection doc = null; string content = null; string documentTemplateName = string.Empty; Encoding encoding = Encoding.UTF8; try { string fetchXML = @”<fetch version=’1.0′ output-format=’xml-platform’ mapping=’logical’ distinct=’false’> <entity name=’documenttemplate’> <attribute name=’content’ /> <attribute name=’documenttype’ /> <attribute name=’name’ /> <attribute name=’status’ /> <attribute name=’modifiedon’ /> <attribute name=’modifiedby’ /> <attribute name=’description’ /> <attribute name=’languagecode’ /> <attribute name=’associatedentitytypecode’ /> <order attribute=’documenttype’ descending=’false’ /> <order attribute=’name’ descending=’false’ /> <filter type=’and’> <condition attribute=’documenttemplateid’ operator=’eq’ uitype=’documenttemplate’ value='” + documentTemplateId + @”‘ /> </filter > </entity > </fetch > “; doc = _service.RetrieveMultiple(new FetchExpression(fetchXML)); if (doc != null) { if (doc.Entities.Count > 0) { content = doc[0].Attributes[“content”].ToString(); documentTemplateName = doc[0].Attributes[“name”].ToString(); } byte[] textAsBytes = Convert.FromBase64String(content); File.WriteAllBytes(@”C:\Users\test\Desktop\” + documentTemplateName + “.docx”, textAsBytes); } } catch (Exception) { throw; } } } } Step 3: When the code is run it downloads the document template on the your PC and the document template is named after the template in CRM. Conclusion: This is very helpful as it can be used in another environment by simply uploading the template. To import the word template we can navigate to Settings > Templates >Document Templates and then upload the template.
Share Story :
Call Workflow directly from a button using Ribbon Workbench
Introduction: In this blog we will demonstrate how to call a workflow directly from a button without any custom JavaScript code. Implementation: Step 1: Create the required workflow. In this example i have created a simple workflow on the opportunity and remember to select the “As an on-demand process” option. Step 2: After the workflow is created store the GUID of the workflow. To get the GUID select the workflow and copy down the ID from the URL as shown in the below image. Step 3: Now create the custom button on Opportunity entity using Ribbon Workbench. Step 4: Create a new Command and click on “Add Action>JavaScript Action” as shown in the image. Step 5: In the library option write the following “/_static/_forms/form.js” and in the Function Name field “Mscrm.FormAction.launchOnDemandWorkflowForm“. Then as shown in the above image add two Parameters as follows: Crm Parameter = PrimaryEntityTypeCode String Parameter = “GUID of the Workflow”. Step 6: For the final step add the command to the newly created button by simply selecting it from the drop down in the properties section. Step 7: Now when we click on the button that we created we get the following message. On clicking OK the workflow will run. This is a helpful as it can be done quickly without using any custom code.