Category Archives: D365 General
Issue faces in retrieving 5000+ records using Web API
Introduction: While using Fetchxml queries to retrieve more than 5000 records, first page will give you 5000 records and paging cookie. Paging cookie will help to retrieve additional records. For additional records, we need to set the paging cookie in the fetch tag. Setting the paging cookie: When the fetch query is executed it brings the paging- cookie with it in the resultant response. The paging cookie is attached to the next Fetch XML The paging cookie consists of the first and last record details. Name and the GUID of the records. When trying to execute fetch XML request. it started throwing “Page Cookie Malformed” exception. This is because there is a special character present in the paging Cookie. You can see in the above cookie that Name has “&” which is the replacement for character “&”. This breaks the fetchXml request.There can be any character present in the record name such as (‘s). Even (‘) breaks the fetch XML. Thus, we need to encode the paging-cookie before it is inserted in fetchXml. pageCokies.replace(/&/g, ‘&’); This will help to solve the issue and we can retrieve more than 5000 records.
Share Story :
Upgrading D365 Online Portals to v8.3 in July Update
In this blog, we will see how can we upgrade the D365 online Portal to v8.3 and what are the new features that are available in this upgrade. Pre-Requisites: D365 CRM Portals D365 CRM Environment Overview: The new version 8.3 for D365 online Portals is made available in the July update provided by Microsoft. Along with the new version of portals there are some amazing new features and functionality changes which are mentioned below. User has now control over the time setting as to when was the portal upgraded Administrative wizard tile is added to the Portal module in CRM. User can now clear cache from the portal to improve the performance We will now see how the user has to upgrade the portal to the new v8.3 in the following process Process: Step 1: The user will have to go the Instance page of the Dynamics 365 Administration Center. In the Instance page click on the edit button to the side of ‘Solutions’ as shown below. Step 2: In the list of Managed solutions for the user’s organization, if the portal hasn’t been upgraded the user will see ‘Upgrade Available’ for the portal if installed previously as shown below On the left, we can see the details of the upgrade that will be applied to the existing portal solution. Click on the Upgrade button as shown to initiate the upgrading process. Step 3: On clicking on the Upgrade button user will get a prompt for Terms and Service click on ‘Upgrade’ to Proceed as shown below The user will have to wait for the upgradation process to complete. Once the upgradation process is complete, the user can check the current version of the portal by going to the following link: https://[portaladdress].microsoftcrmportals.com/_services/about. If the user has the v8.3 portals along with admin sign in can view more details of the portals
Share Story :
Using the Administrative Wizard for D365 Online Portals
Introduction: In this blog, we will see how can we use the new feature of the ‘Administrative wizard’ for the D365 Online Portals Pre-Requisites: 1. D365 CRM Portals 2. D365 CRM Environment Overview In the new update of D365 Online Portal for v8.3, a new feature has been introduced which is the ‘Administrative wizard’ which enables the user to customize the portal by allowing to add an entity to the portal. The user needs to decide as to which entity (i.e. a custom entity or an out of box entity) is to be added prior before adding it to the portal The administrative wizard enables the user to also add entity components like entity form, list, web pages etc. Scenario: In the following scenario, we will add a custom entity with a form and view which is configured prior to the process of adding it to the portal. Process: Step 1: To initiate the process, the user will have to navigate to Portal > Administration > Portal Management as shown below. This will start the administrative wizard. Note: The ‘Portal Management’ Tile is only visible for 8.3v of D365 Online Portals. Step 2: Now select ‘Create Portal Content’ from the two options under Portal Management as shown below. A dialog box will appear after selecting the above mentioned option which will allow the user to create a web page and to display a entity which is optional depending on the requirements of the user. Step 3: In the dialog box the user will have to enter the following details like the name of the portal website, page name, title, layout and partial URL. Select the publishing state as ‘Published’ as shown below. The user can get additional options on enabling the entity in the page by changing the value of the ‘Display Organization entity in the portal’ to ‘Yes’ which is ‘No’ by default. On selecting Yes the following options appear as shown below: 1. The user can select the entity from which he would want to use a particular view. 2. Select the view that is to be displayed. 3. Finally select the Form that is to be displayed. The user wants can allow record creation and anonymous access by toggling on the options to ‘Yes’ or ‘No’. Once all the details have been entered click on the create button to the bottom of the dialog box. Step 4: The user will be automatically redirected to the Portal> Web Page option in CRM where a Web Page is created which consists of the entity list details entered in the previous step. In the Child page section will include the create, edit and details web pages with entity forms associated with it as shown below. Conclusion: Thus, by using administrative tool we can create and expose entity information effortlessly and easily on the D365 Online Portal.
Share Story :
Set Customer Type field in D365 Javascript Web API
Introduction: This blog explains how to set Customer Type field in D365 Javascript Web API. Problem Statement: We get error while setting value of Account lookup on Contact in D365 Javascript Web API as below: “An undeclared property ‘customerid’ which only has property annotations in the payload but no property value was found in the payload. In OData, only declared navigation properties and declared named streams can be represented as properties without values.” Solution: We can achieve this functionality by adding suffix entity name to the schema name of the field. Steps of Implementation: Below code demonstrates how to set Account on Contact. entity[“parentcustomerid_account@odata.bind”] = “/accounts(” + Account_GUID + “)”; Below code demonstrates how to set Contact on Contact. entity[“parentcustomerid_contact@odata.bind”] = “/contacts(” + Contact_GUID + “)”; Note: This issue arises when lookup attribute of the entity can accept multiple types of entity references below are common examples 1. Customer on Incident 2. Customer on Contact 3. Customer type field on Custom Entity. Conclusion: We can resolve issue for setting Customer type field in Javascript D365 Web API by adding suffix entity name to the schema name of the field.
Share Story :
How to add direct links into Dynamics 365 Site Map
This blog consists of steps to add an external link to navigation bar in the application using new sitemap editor in Dynamics 365. Steps to be followed are given below: Create an HTML Web Resource in CRM consisting of below code. <html> <body> <script> //open link in new window window.open(“https://www.google.com”); </script> </body> </html> Open the sitemap editor and add a new subarea and the created web resource into your sitemap Publish your configurations and click on Google Search in the Navigation to check the results: Behaviour: On click on the link, the link opens in the new tab.
Share Story :
AX 2012 R3 Commerce Data Exchange Service: Real Time Service Installation
Introduction: Real-time Service is an integrated service that provides real-time communication between Microsoft Dynamics AX and retail channels. Real-time Service enables individual point of sale (POS) computers and online stores to retrieve certain data from Microsoft Dynamics AX in real time. Redeem loyalty points Issue and redeem credit memos Create and update customer records Create, update, and complete sales orders Receive inventory against a purchase order or transfer order Perform inventory counts In AX 2012 R3, Real-time Service is a Windows Communication Foundation (WCF) service that must be installed on a website in Internet Information Services (IIS). 1. Run AX 2012 R3 Setup. 2. Select Microsoft Dynamics AX Components. 3. Select “I accept licence Terms” and click on Next button. 4. Click on Add or modify components. And click on next button. 5. In Add or Modify Component list. Select “Real time Service” under Commerce Data Exchange. And Click on Next button. 6. Setup will check prerequisite components for Real Time Service. (Note: – Make sure that there should not be any error). Once its Done , click on next button. 7. In Below Screen you have to configure below parameter. ( this is most IMP Steps) Application name – The name of the web application that hosts Real-time Service. Website name – The name of the website that hosts Real-time Service. App pool name – The name of the application pool that Real-time Service runs in. User name and Password – The credentials for the application pool identity. HTTPS port – The port on which Real-time Service receives secure HTTP requests. You can specify any available port. Verify that the port is open in Windows Firewall. TCP port – The port on which Real-time Service receives TCP requests. You can specify any available port. Verify that the port is open in Windows Firewall. SSL certificate thumbprint – The thumbprint for your Secure Sockets Layer (SSL) encryption certificate. You must obtain a valid, registered certificate from a provider. 8. Setup will re-validate the Prerequisite components as per configuration. Once it’s Done click on Next button. 9. Real time service is now ready to install. Click on Install button to start the installation. 10. Once Installation is done below screen will appear. 11. After this close all the window. And go services. In Services you can able to see Microsoft Dynamics AX Commerce Data Exchange : Real-time Service.
Share Story :
CRM Tip: Issue with checking Security role GUID of custom security roles
Problem Statement: We often encounter a scenario where we need to perform some operations based on the fact if the user has a particular security role. We also know that the GUID of a custom security role created by us remains the same, even if is installed in some other environment. Consider the following scenario: I want to check if the logged in User has “Custom View Only Role”, I want to hide some fields on the form. Also, the role – “Custom View Only Role” is created by me. Common Solution: For the above problem, this is how a developer would proceed: Get the GUID of the security role, and hardcode it for checking. Get all the User roles of the logged in user. Iterate on all the roles and check if any of the roles from the user roles match the GUID of the “Custom View Only Role”. If any match, then returns true and based on this perform the required operation – in this case, hide some fields. This is how the code would look: function CheckUserRole() { // GUID of the custom role that you created. var CustomViewOnlyRoleId = “XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX”; // Get all the roles of the Logged in User. var currentUserRoles = Xrm.Page.context.getUserRoles(); for (var i = 0; i < currentUserRoles.length; i++) { var userRoleId = currentUserRoles[i]; if (userRoleId.toLowerCase() == CustomViewOnlyRoleId.toLowerCase()) { // Return true if the Role matches return true; } } return false; } Issues with the above Solution This will only work if the D365/ CRM Organization has only root Business Unit and no child business units It will fail if there are any child BUs and the logged in user is in any of the Child BU and also has the “Custom View Only Role”. In this case, the function will return false, even though the User had the role Why this happens: This happens because, in CRM, a copy of all the roles is created for each BU. So the GUID of all the same role within Different BU will be different. Alternative Solution: We can check with Role name instead of GUID, and tweak the above code. But checking with Role names is not a good practice since the role names can be changed in the future. Better Solution Since the issue is with copy of the same role for different BU, we can solve this by leveraging the “Parent root role id” There is a field on the Role entity called Parent Root Role. This stores the reference of the Root role on all the copies of each BU role. So even though the role ids will not be same, the Parent Root Role Id will be same for all the copies. Below is the code to leverage the parent role id and check if the logged in user has the role using the Role GUID. You can also find this code in My Github function CheckUserRole() { // GUID of the custom role that you created. var CustomViewOnlyRoleId = “XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX”; var returnValue = false; // Get all the roles of the Logged in User. var currentUserRoles = Xrm.Page.context.getUserRoles(); // Get the Parent roles for each, and then compare. GetParentRoles(currentUserRoles, function (result) { for (var i = 0; i < result.value.length; i++) { if (result.value[i][“_parentrootroleid_value”].toLowerCase() == CustomViewOnlyRoleId.toLowerCase()) returnValue = true; } }, function (error) { alert(error); } ); return returnValue; } function GetParentRoles(roles, successCallback, errorCallback) { var fetchXml = ”; fetchXml += ‘<fetch version=”1.0″ output-format=”xml-platform” mapping=”logical” distinct=”false”>’; fetchXml += ‘<entity name=”role”>’; fetchXml += ‘ <attribute name=”name” />’; fetchXml += ‘ <attribute name=”businessunitid” />’; fetchXml += ‘ <attribute name=”roleid” />’; fetchXml += ‘ <attribute name=”parentrootroleid” />’; fetchXml += ‘ <order attribute=”name” descending=”false” />’; fetchXml += ‘ <filter type=”or”>’; for (var cnt = 0; cnt < roles.length; cnt++) { fetchXml += ‘ <condition attribute=”roleid” operator=”eq” value=”{‘ + roles[cnt] + ‘}” />’; } fetchXml += ‘ </filter>’; fetchXml += ‘</entity>’; fetchXml += ‘</fetch > ‘; MK.WebAPI.Retrieve(“roles”, null, fetchXml, null, successCallback, errorCallback, true, null, null, false); } In case of queries or feedback, please comment on the post below.
Share Story :
CRM Tip: How to Check Security Role in Plugins – Correct way
Problem Statement: We often have requirements to perform some action based on certain security role. For ex., we only want System Administrator to delete particular record, and no one else should delete irrespective of their security access. There are many ways to achieve this, but many of the times the solution is not foolproof Incorrect/ Misguided Solution: Generally developers achieve the above requirement by using plugin with below steps: Get User ID from the plugin context. Get all the roles of the user Loop and check if any of the role name is “System Administrator”. If Step 3 is true, then allow delete, else restrict delete This solution works most of the time, but this won’t work if the client is using any other language than English in CRM. Since role names are customized based on language, the above plugin won’t find any user with the System Administrator name of the role. Solution: For language proof solution, we must use the role template lookup on the Role entity. For OOB security roles, there is a role template GUID which does not change based on environment. For System Administrator, the Role Template ID is “627090FF-40A3-4053-8790-584EDC5BE201” The following code will get the System Administrator properly. You can find the sample plugin on my GitHub as well. public bool HasAdminRole(Guid systemUserId) { Guid AdminRoleTemplateId = new Guid(“627090FF-40A3-4053-8790-584EDC5BE201”); QueryExpression query = new QueryExpression(“role”); query.Criteria.AddCondition(“roletemplateid”, ConditionOperator.Equal, AdminRoleTemplateId); LinkEntity link = query.AddLink(“systemuserroles”, “roleid”, “roleid”); link.LinkCriteria.AddCondition(“systemuserid”, ConditionOperator.Equal, systemUserId); return service.RetrieveMultiple(query).Entities.Count > 0; } Note: This can be done for other OOB roles as well like Sales Manager, Sales Person, etc. For custom roles, the role template Id is empty. If the custom roles are created by you, then you can used the Role Id (Unique GUID of Role entity) for querying instead of names.
Share Story :
Connection Entities in Dynamics 365
Overview: Connection entities provision an easy way to connect and describe relationships between two records in D365 CRM. This is supported across most Entity types in Dynamics 365. Some of the features of Connection entities are as follows: All Business and Custom entities can be enabled for Connections. Provision to add descriptive information between the relationship between the 2 records. Enabling Connections for an Entity: In my example below, I’ll enable Connections for 2 custom entities – I have a custom entity called Family Members and have these records details of Family Members like their blood groups and medical history. This entity is a child entity of another customer entity called Patient. Connections must be enabled for this custom entity at the entity level as shown below: Connections need to be enabled on both entities between which connection is to be made. Once Connections have been enabled, navigate to the record and navigate to the related records, you’ll see Connections is now available. Connection Roles: Connection Roles are the description that defines in what way is record A related to record B. Connection Roles can be added to a Solution or even created as below: In a solution, look for Connection Roles on the left hand menu Then, create a Connection (Existing ones in an Unmanaged Solution can be added as well) I am creating a new Connection Role by the name Father and I’ve enabled the same only for Patient entity. and Family Member After saving the record, I’ll create a Matching Connection Role to the role Father I just created. Now, I’ll create a matching Role called as Son Now, the two roles have been created which match each other Associating Records: Once my Connections have been enabled on source (connection from entity) and target (connection to entity), I’ll associate the two records as follows: I will navigate to the Family Member entity I created above and will associate a record with a record to Patient entity. This way, I can derive what is the relation between the family member and the patient. In the Connection Associated View above, I’ll associate the Family Member Gary to the Patient. So I’ll select To Another in the connection menu as shown in #1 above. Then, find the Patient Alexander James which I created in the Connect To tab as shown below. And then I relate the current record to the target record as the Father. Note: As soon as Father was selected in the Connected To tab, the Details tab auto-filled Son as it was the only role associated with the Father when we created Connection Roles in above section in this blog. In case there are multiple Connection Roles associated with one Role, the Details section’s As This Role field will be empty for you to select the related role from. And the record is saved as below. Likewise, a record can be connected to multiple other records as well. Retrieving Connections: Connections are useful if you want to draw reports, graphs or charts.
Share Story :
Dynamics CRM behaviour on deletion of User
Introduction: Have you ever wondered what happens to the user owned records in CRM when the user itself is deleted from CRM? Will the records get deleted? Or Will it be assigned to some other user? What will happen to the existing system jobs? Let us see in the below example. Description: Suppose there is a user named “Somesh Siripuram” and this user has its own account records. The owner of this records is “Somesh Siripuram”. Now the user is being deleted from the admin portal and no longer has access to Office 365 and CRM. Login with system administrator and check for the deleted user. The user will be listed in “Disabled User” view. When you open the user the email address and the user name of the user will be changed and some number appears Now, it’s time to check the deleted user owned records Thus, we can see that records neither gets deleted nor the owner of the records get changed. Manual assigning of records to another user is required. Other effects: Waiting jobs will remain as waiting until it is cancelled. New system jobs (where workflow owner equals to disabled user) will fail. You need to change the owner manually, they are not auto assigned to system