Category Archives: D365 General
Create Notes Attachment using WebAPI
Introduction: After the introduction of web API in CRM, user can execute all the requests which is possible through C# or JavaScript. In this blog I will explain how to attach a document to record using the postman. Description: Notes attachments has been tested with a custom entity and tested on Postman. To work this, you can follow the below blog to get the Access code. https://www.magnetismsolutions.com/blog/johntowgood/2018/02/12/dynamics-365-online-authenticate-with-user-credentials METHOD: POST URL: https://instancename.crm.dynamics.com/api/data/v9.1/annotations Authorization: Header: Content-Type:application/json In Authorization select the type Bearer Token Type and pass the token value which we got before. Body: You need to pass the below 4 parameters with value. Key Value subject Filename objectid_cf_document@odata.bind documentbody Json Body: { “subject”: “Test From Web API”, “filename”: “Untitled2.png”, ” objectid_cf_document@odata.bind “:”/cf_documents(23e6ee7c-5812-e911-a96b-000d3a3638df)”, “documentbody”:”iVBORw0KGgoAAAANS……….” } CODE: Postman Description: Image attached you need to pass it as base64 string as document body. var settings = { “async”: true, “crossDomain”: true, “url”: “https://instancename.crm.dynamics.com/api/data/v9.1/annotations”, “method”: “POST”, “headers”: { “Content-Type”: “application/json”, “Prefer”: “return=representation,odata.include-annotations=\”OData.Community.Display.V1.FormattedValue\””, “Authorization”: “Bearer eyJ0eXAiOiJKV1QiLCJhbGci………………………..”, “cache-control”: “no-cache”, “Postman-Token”: “b57b2d5b-c8d5-4f26-abf0-a3ea1f499637” }, “processData”: false, “data”: ” {\r\n \t \”subject\”: \”Test From Web API\”,\r\n \”filename\”: \”Untitled2.png\”,\r\n \”objectid_cf_document@odata.bind\”:\”/cf_documents(a60fbc96-f00f-e911-a96b-000d3a3638df)\”,\r\n \”documentbody\”:\”iVBORw0KGgoAAAANSUhEUgAAAe8AAAE8CAIAAABmQa4bAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAM2SSURBVHhe7P0HtCTHeSaIVqUtb2/dquu9ap+9JywAz87LbUdPubNjmbNzmatjmatxZHhxDAthtnMPDSe51EU1C52S3dcjAwMDA8L4hx9qM9Vj3FhQwdK20PKXEZw1D453rlLydl8RAtathuyPWJoXqpHCdo67TWdcteEJEiZtBzN+YPX1JSgy5wijzzx33aq5oC8xKr3THqD8k0Ab576aVAZTjfpqoHTyJwJBq6cCvlXgufY+1px6+rqallZ2djPfhiZ7Eon3JHmn+Qdbrb7Lgd+/9PFjWruLHG+8X89zn7vmT8EV82uF37isV6e+OdfhyZv/pJig5D1w5L/ut/Q8RPvpStR4bjzxf+BzJN/+E1ofNTgaRXa/r7imDP+T/+wOtCefkM05TGGwW8ZBF1VoOl9x/5hezVPr1IoFArlEWEbNT9z5nR69WvBbN72G3UUykNNJEKHOigPO1vfFkKhUCiURxGq5hQKhfJtgKo5hUKhPPoYDP8fI9Uy7N6b03EAAAAASUVORK5CYII=\”\r\n }” } $.ajax(settings).done(function (response) { console.log(response); }); In the above code I have posted- Post Request Response
Share Story :
Share SharePoint document programmatically
Introduction: Sometimes it is required to share the certain documents with outside users. It is possible that user can share that document as hard copy. If that document is hosted on SharePoint user can make a shareable link. Description: Sharing a document to the outside users are possible via directly going to SharePoint and creating a shareable link. But what if you want to generate a shareable link using the C# code. You can follow below code to generate shareable link in Online SharePoint. 1. Get the link You need to pass the document link to below function as shown. currentLink = https://organization.sharepoint.com/cf_car/JTN_89330b3c-beb5-e811-a968-000d3a324f4c/Untitled2.png 2. Get the base url of your SharePoint and generate the service context using (var context = new ClientContext(Model.SharePointBaseURL)){} 3. Authenticate the user foreach (var c in Model.AdminPassword) passWord.AppendChar(c); context.Credentials = new SharePointOnlineCredentials(Model.AdminUserName, passWord); 4. CreateAnonymousLink method which will generate the shareable link var orgEditLink = Web.CreateAnonymousLink(context, currentLink, true); 5. Execute the query context.ExecuteQuery(); 6. Finally get the public link editUrl = orgEditLink.Value; Complete code: private static string UpdateLinkTOShareable(string currentLink, Entity document) { string editUrl = string.Empty; using (var context = new ClientContext(Model.SharePointBaseURL)) { var passWord = new SecureString(); foreach (var c in Model.AdminPassword) passWord.AppendChar(c); context.Credentials = new SharePointOnlineCredentials(Model.AdminUserName, passWord); try { var orgEditLink = Web.CreateAnonymousLink(context, currentLink, true); context.ExecuteQuery(); editUrl = orgEditLink.Value; } catch (Exception ex) { } /*Code to make link Public End*/ return editUrl; } }
Share Story :
Shortcut to Settings from Unified Interface: D365
If you’re spending time looking and wondering that you always need to go to the app switcher to go the Settings from the Unified Interface, you need to do the following – Once you are in the Unified Interface, click on the Gear icon next to the help icon on top-right corner as shown below and click Advanced Settings – Right on the next tab, Settings with the classic UI is shown – And there’s nothing else on the SiteMap. Hope this helps!
Share Story :
Bulk Clear field values in D365
Introduction: A very handy approach for admins and users of Dynamics 365 who want to bulk clean up field values – And just selecting them in Bulk Editing them as shown below doesn’t help!! So here’s the scenario – You want to clear the selected records for their Credit Score field. Because primarily, you can commonly put a value in a field using Bulk Edit, but not clear the value. Workaround: What you can do instead, create a quick and simple workflow to clear the field. 1. Create an On-Demand workflow on Contact entity with an Update step for Contact 2. In the Update step, point to the field and then select the Operator on the right hand side to select Clear. 3. Make sure the Clear appears on the field you want to Bulk Update. 4. Once done, save and Activate the workflow. Run on the selected records you want to clear at once. 5. The values will not be cleared for these records. Hope this helps!
Share Story :
Integrating SharePoint with D365 Portal
Introduction: This blog explains how we can add files from D365 Portal directly into SharePoint which was long awaited feature missing from Portals. Below are the Steps: Step 1: Set up SharePoint integration from Portal Admin Center 1. Go to the Dynamics 365 Administration Center page and select the Applications tab. 2. Select the name of the portal for which you want enable SharePoint integration, and then select Manage. 3. Click on Set up SharePoint integration –> Enable SharePoint integration. 4. Click on Enable button it will then ask you to sign in again. 5. Enter D365 CE (MS CRM) credentials to sign in again. 6. Click on Accept to grant the required permissions. 7. You will get the below message. Step 2: Enable document management for entities (Customization in D365 CE) NOTE: If document management is not enabled already then follow below steps. Go to Settings –> Document Management –> Document Management Settings Select entity Click on Next and Finish. Step 3: Configure the appropriate form to display documents We need to add Document Location subgrid in the form which will get displayed in portal. (NOTE: Add subgrid on Edit form to edit the record in portal only.) Step 4: Creating and Assigning Entity Permissions. 1. Create entity Permission of Scope “Global” for Case (Incident) Entity. 2. Click on “+” to Add Child Entity Permission for “Document Location”. 3. Click on “New”. 4. Enter below details. Entity Name: Document Location Scope: Parent Parent Entity Permission: Case_Global(Select the name of parent entity from lookup) Parent Relationship: Select the name from drop down. Select all the Privileges. 5. Save the record. 6. Your Global Entity Permission should look like below. 7. After Creating Entity Permission successfully assign web role to the entity permissions. Sign in to Portal 1. Open any Case record. 2. You can see Document Section below from where you can “Add files” or Create “New folder” 3. Click on “Add files” button you are shown a pop-up window from where you can choose the files to upload. 4. You can see the New Folder is created in SharePoint for that Particular Case and file is also uploaded inside respective folder. 5. Click on “New Folder” to create new folder this will get created inside the parent folder “Case_CaseGUID” in SharePoint. 6. From portal you can go inside the folder and then upload files which gets uploaded inside the respective folder in SharePoint. “Add Files” in newly created folder. New Folder and Files in SharePoint.
Share Story :
Run OnDemand Workflow in D365 CE UCI Apps
Introduction: This blog explains the steps on how to enable OnDemand Workflow in D365 CE UCI Apps. Scenario: After clients are upgraded to D365 CE V9 version, Users are unable to use Classic App functionality to run OnDemand Workflows which was showstopper since it was routine task and much needed functionality. Steps: Below are steps to be performed for enabling functionality 1. Admin user should enable the “Microsoft flow” option for all the users. Below are the steps: Navigate to the ‘users’ in Office 365. Post navigation, open a specific user. Enable license for “Flow for Dynamics 365” in D365 CE Plan. (below screenshot for reference). 2. Enable setting to Show Microsoft Flow in Sitemap. Navigate to Settings → Administrator →System Settings by System Administrator Role User. Open Customization Tab and Enable Microsoft Flow option. 3. Navigate to any Entity below screenshot for Account. Open Account Entity record. Navigate to Flow button on Ribbon and expand options, you will view all OnDemand Workflow for Entity under Run Workflow header. Conclusion: This is how enabling Microsoft Flows setting on specific environment allows Users to run OnDemand Workflows in UCI Apps of D365 CE. Hope the above process helps!
Share Story :
Create Folder Structure in SharePoint using MS Flows
Introduction: In this blog we will see how we can create folder structure in SharePoint for Leads when the record is created in CRM using MS Flows Pre Requisites: SharePoint Integration must be enabled for the required entities Implementation Step 1: Here in our Flows we have used “Create of a record(Leads)” as trigger condition. Step 2: Then we create the folder structure in SharePoint using the “Create File” action Here we will create a text file which can be deleted later if not required. Folder Path: /Lead/Topic_toUpper(replace(triggerBody()?[‘leadid’],’-‘,”)) Here “Topic” is Dynamics value and for the record ID copy paste the expression written above in the Expressions tab and add it at the end of the Folder Path. After we have created the folder structure if the file is not required we can delete the text file by adding the delete step as shown below Step 3: We will also store the Folder ID in a variable “FolderId” to use in the later steps Step 4: Now we will create the same folder structure in CRM (Document Location) Here for the parent site or Location we have we have added the GUID of the Parent Document Location site for Leads. We can get this from the URL of the Parent Document Location record from Advanced Find (Document Location Entity) Lead document location record URL: https://org.crm8.dynamics.com/main.aspx?etc=9508&extraqs=%3f_gridType%3d9508%26etc%3d9508%26id%3d%257b1957C431-5F15-E911-A96F-000D3AF29269%257d%26rskey%3d%257bF5B008AC-07D9-4554-8509-2C05767BFF51%257d&histKey=17520860&newWindow=true&pagetype=entityrecord&rskey=%7bF5B008AC-07D9-4554-8509-2C05767BFF51%7d#371473802 Step 5: Similarly we can also create sub folders within the main folder as per the requirements Hope this Helped!
Share Story :
Use setFormNotification (Client side JS) in D365 v9 while Real-Time workflow is executing
Often, when a real-time workflow is being executed in the background, users don’t know how long it will take for the processing to finish. setFormNotifications in D365 v9 come handy! Scenario Here’s how I put my scenario – I call the Real-Time workflow using JS, example, on change of a certain field or the JS being called from the Ribbon button. The JS will trigger the Real-Time workflow I have. Now, while the Real-time workflow is running, the user doesn’t know it has been called and should the user retry the same action? Here’s when the form notification is vital. While the processing is happening, the message will remain as a notification on the form. Once the processing is complete, the notification will be cleared. JS Implementation: For the JS code implementation, the function to call the workflow needs ProcessJS which is available on https://github.com/PaulNieuwelaar/ So on the Form, I’ll add my file after ProcessJS file. Here’s the Account Form code I wrote. I created a JS file to call the Real-Time workflow. In the above code, the Xrm.Page.ui.setFormNotification(Message, Type of notification, Unique Identifier); This will set the notification. Page.ui.clearFormNotification(UniqueIdentifier); will clear the notification from screen. Using this, When the Process enters in Processing mode, the message is shown on screen as “Please wait while processing”. And once the execution is finished successfully, the notification is cleared. Similarly, you can even use this approach for WebAPI calls and have clearFormNotification set in the Success/Failure callbacks. Hope this helps!
Share Story :
Send Emails using WebApi in MS CRM
Introduction: This blog explains how to Send Emails using WebApi in MS CRM. Request: Post URL: <your instance url>/api/data/v9.1/ emails (<guid of the email record>)/Microsoft.Dynamics.CRM.SendEmail Header: Content-Type: application/json Parameter To be send in body: Parameter Value Comment IssueSend False If value is set as false, then email is market as sent only in MS CRM. IssueSend True If value is set as true, then email is sent and as well as marked as sent in MS CRM. Body: { “IssueSend”: “true” } Response:
Share Story :
Audit User Access in D365
One of the most common asks as an administration is to know when the user started accessing the system and from where. In your Dynamics 365 Customer Engagement apps, you can enable Auditing for User Access. Enable Auditing of User Access You need to enable this feature once you enable Auditing on Organization level. Then, you can enable User Access Auditing as well Navigate to Settings > Administration > System Settings and under Auditing tab OR Settings > Auditing > Global Audit Settings Once the Auditing for User Access has started, the Audit Summary will record this – And whenever a User logs into Dynamics 365 via the Web Application, Phone app or WebServices that provide authentication, the Auditing will be logged as shown below – The Operation will be Access and the Event will be User Access via Web or User Access via Web Services. If you want to enhance user login, you can quickly enable Multi-Factor Authentication for the users, read my blog on MFA here. Hope this quick tip helps.