Category Archives: D365 General
Create and Associate records using Xrm.WebApi
Introduction: In this blog we will demonstrate how to create and associate records using Xrm.WebApi which provides methods to use Web Api to create and manage records. Implementation: Step 1: The syntax to create a new entity record is as follows: Xrm.WebApi.createRecord(entityLogicalName,data).then(sucessCallback,errorCallback); Here entityLogicalName(string) and data(object) parameters are required. The “data” parameter is a JSON object defining the attributes and values for the new record. Step 2: In this example we will create a sample account record along with a primary contact for that account, associate an opportunity to the account and create task and notes for the opportunity all in a single operation. This type of process is called as a deep insert. The code for the same is as shown below: var scripting = { recordCreation: function () { var data = { “name”: “CRAYONS LTD.”, “description”: “This Account is Created using a Web API”, “creditonhold”: false, “telephone1”: “9954565154”, “address1_city”: “Mumbai”, “primarycontactid”: { “firstname”: “Clinton”, “lastname”: “Dmello” }, “opportunity_customer_accounts”: [ { “name”: “Opportunity Associated to CRAYONS LTD.”, “Opportunity_Tasks”: [ { “subject”: “Task Created” } ], “Opportunity_Annotation”: [ { “subject”: “Note Created”, } ] } ] } Xrm.WebApi.createRecord(“account”, data).then( function success(result) { console.log(“Account Created with ID” + result.id); //perform operations on record creation }, function (error) { console.log(error.message); } ); } }; Step 3: In order to associate to an existing record @odata.bind annotation can be used. For Example: “primarycontactid@odata.bind”:”/contacts(GUID of the contact)”. Screenshots 1. A New Account is created with the name “CRAYONS LTD” and in the primary contact file the primary contact is set with the name Clinton Dmello as set in the code. 2. Also an opportunity is associated to the account as shown below in the associated view. 3. In the opportunity we can see the newly created task in the activities and a note as shown below. Hope this helped!
Share Story :
Actionable Audit App to access audit logs in D365
Introduction: In this blog we will see how audit logs in D365 can be fetched that can be used for reporting purposes. Auditing helps to track changes made to the data in D365. The System Auditing entity cannot be accessed. Actionable Audit is a App by Microsoft Labs in which the required audit logs can be stored in the actionable audit entity which can be used later on by fetching the records of that entity. This audit log can be helpful to create Dashboards in Power BI, create reports etc to get meaningful information from the data. Implementation: Step 1: First we enable the auditing for the organization(globally) in Settings > Auditing. Step 2: We then enable auditing for the required entities and fields. Step 3: Download the Actionable audit app from the AppSource. Step 4: After accepting the terms and condition is done, it will take some time to install the solution as shown in the notification below. Step 5: In the plug-in registration tool we can see the assembly MicrosoftLabs.ActionableAudit is present. Step 6: Out of the box some steps are already registered as seen below Note: Only if the field is enabled for auditing the logs will be stored in Actionable Audit entity. Step 7: If required, the out of the box plugin steps can also be unregistered. And we can also add custom entities to the list. The pre-image and post-images also must be registered for different message which is shown in the user guide in the AppSource. Step 8: After the logs are created they are stored in Actionable audit entity as shown in the below example. Hope this helped!
Share Story :
Manually Clearing Cache on ADX Portals to reflect changes made to Portals through CRM
Introduction: People using ADX Portal often face the issue of clearing cache due to which changes aren’t being reflected on the frontend. In this blog we will see how a user can manually clear cache in ADX Portals to reflect changes made to Portals through CRM. Pre-Requisites: ADX Portals CRM Environment Scenario: One scenario mostly faced is that notes added in CRM in the activity section of a particular case aren’t appearing in the notes section on the case entity form in portals. The problem can be resolved by clearing the cache of the portals which will help to reflect the changes made to portals via CRM. We will see below how we can resolve the issue by using manual cache clearing technique. Process: Step 1: User while adding notes in CRM will have to add the prefix as *WEB* to the note. For eg. “*WEB*This note states the resolution of the case Step 2: The user will have to save the following ” javascript:var url=document.location.protocol+’//’+document.location.host+(document.location.host.indexOf(“demo.adxstudio.com”)!=-1?document.location.pathname.split(“/”).slice(0, 3).join(“/”):””)+’/Cache.axd?Message=InvalidateAll&d=’+(new Date()).valueOf();var req=new XMLHttpRequest();req.open(‘GET’,url,false);req.send(null);window.location.reload(true);” as a Bookmark in the URL section in the Browser. For Chrome Browser: In Bookmarks section of chrome we will add a new bookmark as shown below: Select “Add new bookmark” to add a new bookmark in the dropdown options Name the bookmark as “Cache Invalidate” and add the following to the URL “javascript:var url=document.location.protocol+’//’+document.location.host+(document.location.host.indexOf(“demo.adxstudio.com”)!=-1?document.location.pathname.split(“/”).slice(0, 3).join(“/”):””)+’/Cache.axd?Message=InvalidateAll&d=’+(new Date()).valueOf();var req=new XMLHttpRequest();req.open(‘GET’,url,false);req.send(null);window.location.reload(true);”. Click on save once done. Enable “Show bookmark bar” which will display the added bookmark to the chrome ribbon. Step3: On opening the case page click on the saved Bookmark “Cache Invalidate” on the bookmark bar which will make the note visible in the note section. Conclusion: In this way we can manually clear the cache which will reflect the newly made changes to ADX Portals.
Share Story :
New Email capabilities in Unified Interface – D365 v9
Overview: After much wait, the new Email feature in the Unified Interface is finally here. So this blog is about what all the new Email functionality can do in the Unified Interface. This feature is only for the Unified Interface. Now, you can see the Email button appearing on the ribbon. In the To field, you can select the record type in more intuitive way without having to load the Lookup view. Rich Text Editing: Now, the new Unified Interface offers Rich Text Editing capabilities wherein you can add new media to your email body. HTML Preview: Even you get to see the HTML preview of your email Preview of the Email You’d definitely want to see what goes out before sending the email out. You can also preview the final email before sending the same. Email: And this is how it looks when received by the recipient Hope this helps to a great start in email editing in D365!
Share Story :
Trick to find the fields Workflows trigger on
Introduction: This blog consists of information on how you can find the triggering parameter of the Workflow. Scenario: There are many workflows on update of a record and which workflow is triggering for which fields and on which fields the workflow is dependent on. It may be handy to identify which fields are being used to trigger workflows. You would open each workflow and check or you could click field in every entity and Check Dependencies. But there is much easier way for it. Solution: We can make use of Advance Find on the Process Entity. There are some fields like 1) Trigger On Update Attribute List 2)Trigger On Create 3) Trigger On Delete 4) Is Child Process This fields can be useful in many ways. Trigger On Update Attribute List has a field list separated by comma. This are the fields on which the workflow triggers.
Share Story :
Retrieve Multiple Records using Web API in Dynamics 365 version 9.0
Introduction: In this blog article, we will be showing how use fetch XML to retrieve multiple records with the new Web API in Dynamics 365 version 9.0 Implementation: Step 1: The retrieveMultipleRecords() method retrieves a collection of entity records. The basic syntax is as follows: Xrm.WebApi.retrieveMultipleRecords(entityLogicalName,options,maxPageSize).then(successCallback, errorCallback); Here the options parameter refers to the query that will decide the data which has to be retrieved from the system. We will be using the fetchXml attribute to specify a FetchXML query to retrieve contacts of a specific account. The maxPageSize indicates number of records to be returned per page. If this is not specified the default value is 5000. In this example we have not specified the maxPageSize. Step 2: First we write the code and upload it as a JavaScript web resource. Code var scripting = { retrieveMultipleContacts(executioncontext) { debugger; var formContext = executioncontext.getFormContext(); var accountId = formContext.data.entity.getId(); var fetchXml = “<fetch version=’1.0′ output-format=’xml-platform’ mapping=’logical’ distinct=’false’><entity name=’contact’ ><attribute name=’fullname’ /><attribute name=’telephone1′ /><attribute name=’contactid’ /><order attribute=’fullname’ descending=’false’ /><filter type=’and’><condition attribute=’parentcustomerid’ operator=’eq’ uitype=’account’ value ='” + accountId + “‘ /></filter></entity ></fetch > “; Xrm.WebApi.retrieveMultipleRecords(“contact”, “fetchXml= ” + fetchXml).then( function success(result) { for (var i = 0; i < result.entities.length; i++) { console.log(result.entities[i]); } }, function (error) { console.log(error.message); } ); } }; Here we take the execution context as the input parameter and we get the form context using the getFormContext() method. This method returns a reference to the form or an item on the form. Using the formContext we get get the account id which is used to fetch the contacts of that specific account. Step 3: On the account form, in the form properties we set the Event to OnSave as shown below. Step 4: In the handler properties we set the function name, in our case it is scripting.retrieveMultipleContacts. And it is important to check the “Pass execution context as the first parameter” checkbox as shown below. Step 5: We see that the account A. Datum Corporation (sample) has two contacts. Step 6: The script runs when the form is saved and while debugging we can see in the console, two contacts are returned in the results. We get the the attributes that were present in the FetchXML query. Hope this article was helpful!
Share Story :
How to Connect with Dynamics 365 and use Lookup Field of Dynamics CRM in PowerApps.
Introduction: This blog explains how to Connect with Dynamics 365 and use Lookup Field of Dynamics CRM in PowerApps. Steps for Creating Connection to Dynamics 365: Go to https://web.powerapps.com Create a new Connection with Dynamics 365. Click on New Connection and search for Dynamics 365. Select Dynamics 365 and click on Create. Enter the Credentials for the Connection. Steps for Creating an App: Go to App and Click on Create an App. Under Start with your data select Phone Layout for Dynamics 365. Now Select Connection and choose a dataset from that Connection. Select the Entity from the list. Click on Connect. PowerApps will create Browse, Details and Edit screen for you. Browse Screen: You can search for the record and see all the records which are created. Detail Screen: It gives details of record which is selected in Browse Screen. Edit Screen: You can create or update the records from this Screen. Important : The current Dynamics 365 connector does not support lookup or option set data types. so we’ll demonstrate how we worked around the lookup limitation. Example: For contact entity there is Lookup field for accounts.To use Lookup Datatype in contacts for account you must add account entity also in PowerApps. Steps for adding Account Entity: Go to View -> Data Source -> Select the Connection Choose Dataset->Select Account Entity ->Connect. Now Make changes on each screen so that you get account name instead of GUID of account entity. Browse Screen: Select the field in which you want to display account name. Under Text Property of that field write : LookUp(Accounts , accountid = ThisItem._parentcustomerid_value , name) Now it will return the name of Account instead of GUID. Detail Screen: Select the field in which you want to display account name. Under Text Property of that field write : LookUp(Accounts, accountid = ThisItem._parentcustomerid_value , name) Now it will return the name of Account instead of GUID. Edit Screen: Steps: Create a new Blank screen name it as account lookup. Add Gallery control inside Blank Screen and set its items property to accounts. Select the next arrow and set its OnSelect property to : ClearCollect( Selectedaccount, { Account: Gallery1.Selected } ); Back() Now Go back to Edit Screen Select the Data Card of Company Name and Go on Advanced Properties and Unlock the Data Card. After Unlocking the Data Card Add search icon inside the Data Card. Now select that Data Card of Company Name and set its Default value to:If(IsBlank(First(Selectedaccount).Account.accountid ) , ThisItem._parentcustomerid_value , First(Selectedaccount).Account.accountid ) Select the Data Card value of Company Name and set its Default value to:LookUp(Accounts, accountid= ThisItem._parentcustomerid_value , name) Select the Data Card and set its update Property to:Gallery1.Selected.accountid Select the search icon and set its OnSelect property to:Navigate(‘account lookup’,ScreenTransition.Fade) Select the Data Card of Company Name Type field and set its Default value to: “accounts” Select the form and set its OnSuccess Property to:Clear(Selectedaccount);Back() Select the Cancel icon and set its OnSelect Property to:Clear(Selectedaccount);ResetForm(EditForm1);Back()
Share Story :
Data Export Service in Dynamics 365 – Part 1
Overview: Welcome to this 2-part blog series on Data Export Service in Dynamics 365. This is an Add-on service made available as a Microsoft Dynamics 365 Online solution that adds ability to replicate D365 Online data to Azure SQL datastore in a customer based Azure subscription. Supported Target Destinations – Microsoft Azure SQL Database Microsoft Azure SQL Server on MS Azure Virtual Machine Data export initially synchronizes schema and data and thereafter, delta changes as they occur. Prerequisites: Your Dynamics 365 Online instance must be December 2016 update or higher Entities should be enabled for Change Tracking. Code is run in the context of a user with Sys Admin role. You’ll need to link your Office 365 to the Azure Subscription i.e. add the Office 365 tenant in the Active Directories of the Azure Subscription Azure SQL Database and user with correct permissions to be setup Install Data Export Service from the App Source from within your Dynamics 365 Dynamics 365: You can get this in the App Source of the Dynamics 365 and add it to your organization. On selecting the same, proceed with the Wizard by accepting terms and conditions And it will setup in the background Once completed, it will appear in the Settings area in Dynamics 365. Settings > Data Export 4. One successfully authenticating with Azure, you’ll see this disclaimer to which you have to click OK to proceed. Setup Azure SQL Database: To be able to run the test successfully, you’ll need to setup SQL Database on your Azure Customer Subscription. 1. I have the following SQL Server created in my Azure account. 2. And the following database created under it. To be able to do #3 below, you must do the following: The subscription must support the volume of data being replicated from your Dynamics 365 instance. Configure an Azure SQL Database server-level firewall rule using Azure Portal. Recommended to Allow access to azure services to be enabled. 3. And finally, connect my SQL to the database hosted on my Azure. Create Access Permissions for Users in SQL Open the Master Database and create a user for the user ‘dataexport1’ for the database. This user is then used in the Dynamics 365 Data Export Service to connect to the database Once done, use the below script to create the user in the created Azure SQL database We gave db_owner access to the user to provide full permissions. Link your Office 365 tenant to your Azure AD (if required) If your Office365 and Azure accounts are different, you can add the Office 365 in your Azure by doing the following: Navigate to Azure portal and then select Active Directory Then, click on + New from the bottom and chose Use existing directory as option and proceed. You’ll be logged out and asked to login again using the Office 365 credentials you want to add. Once signed in, the Office 365 tenant will be linked to your Azure Subscription and seen as below in the Active Directory area Now, what we’ve accomplished so far is – Adding Data Export Service to your D365 instance Setting up Azure SQL and connecting the same from your SQL Adding your O365 tenant to the Azure Subscription (option) In the next part, we will see – Creating Key Vault in Azure to store the connection strings to the Azure SQL Creating a Data Export Profile Testing out the functionality. Key benefits of using Data Export Service. Part 2 of this blog series will be out early next week.
Share Story :
Compare two roles in CRM
Introduction: Managing and understanding security roles in CRM can be tough. One of the Tools on Xrm.Tools is a Security Role Explorer, which tries to help make it easier. Steps to Compare roles in CRM: Go to xrm.tools site on browser. Click on Explore Roles Now button on the left most corner. You need to enter CRM organization credentials. Select Compare Roles buttons. Compare Roles – Allows you to compare two roles and look at what is Unique to each role, Different or the Same. This is great for example when you are trying to decide if you should consolidate some roles. View User Roles – It allows you to provide a user e-mail, it looks up all their roles and presents you a composite view of what their roles provide them. This is great when you have users that have multiple roles, and you want to see what their combined access is. View Entity Roles – You simply need to provide the logical name of the entity. Once provided it will show you all the roles and the access each role provides for that entity. This view is great when you simply want to know which roles have access to a specific entity, and you don’t have time to open 20+ roles up to find out! We will compare roles in this blog. Thus, enter the roles you want to compare. The result will be displayed and you can analyse the security roles and depending on the analysis you can create new roles or add access to the existing roles. You can compare the previous OOB role with the new OOB roles too.
Share Story :
Input Mask on D365 Control
Overview: Now, you may have a requirement where you’d want users to input data in a correct format for better readability and validity. There is a feature for a control where you can achieve this in tablet/mobile app of D365 and on the new v9 version of D365. It is called Input Mask For this example, I’ll demonstrate the feature on the new D365 v9’s Unified Interface. Define Input Mast for a control: Here’s how you can define an Input Mask for a control. Take an example of a Lead where I want business users to enter Business Phone field in a specified format only: Navigate to change the Field Properties on the Lead form: And click on Add Control to add the new type of control for the field. Select Input Mask and click Add. Select where you want the Input Mask to effect and then select the pencil icon to edit the condition Create your format by following the instructions. You can either bind to a value on a field or bind to a static value. I selected to bind to a static value. Confirm your changes and publish the same as below Input Mask Validating user input Since you’ve published the changes, let’s take a look at the Lead form and check the validation message if incorrect format is entered. Navigate to the Lead form in the Unified Interface. And enter the Business Phone which is not compliant to the specified format. You’ll see the validation error. Only when I enter correct format, I’m able to save the same. Hope this quick tip was helpful!