Latest Microsoft Dynamics 365 Blogs | CloudFronts - Page 152

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 :

Dynamically hide and show fields according to a specific condition on a page in Dynamics NAV

If you have a small or a mid-sized business and still running an older version, you must seriously think of Microsoft dynamics nav upgrade. Microsoft is consistently seeing approaches to ad lib the Enterprise Resource Planning Systems or ERPs. Utilizing Microsoft Dynamics NAV Inventory Management, organizations can do undertakings, for example, setting up elective sellers, beware of stock gathering the board, and get the necessary examination report effortlessly.  70 percent of Microsoft Dynamics NAV clients around the globe keep on running old variants of NAV. Albeit past NAV forms have conveyed ground-breaking operational advantages all through its use, moving up to the most recent adaptation takes execution, spryness and interoperability to unheard of levels. One of the prime explanations behind not overhauling is the hesitance.  Introduction: We often have a requirement to dynamically hide or show fields on a page according to a certain condition. Setting visibility properties of the fields to ‘True’ or ‘False’ do not help as they do not work dynamically. They are only set when the page is opened initially. In this article, I will be demonstrating the procedure to show or hide fields dynamically on a page according to a specific condition. Pre-Requisite: Microsoft Dynamics NAV 2017 Procedure: This is the scenario that I was customizing. I was working on two types of contracts i.e. Rental and Lease contracts. The user has to select the contract type on the page. Now if the user selects ‘Rental Contract’ as the Contract Type then a certain set of fields should be visible to the user else, they should be hidden. The first step is to put all the fields that should be shown or hidden dynamically in a separate group on the page. In the above screenshot, I have put all the fields that should be shown or hidden dynamically when ‘Rental Contract’ is selected in ‘Contract Type’ field which is an option field consisting of OptionString ‘Rental Contract and Lease Contracts for Uber and Non-Uber drivers’ under ‘Rental details’ group. Next, go to the properties of the group that contains the fields which should be dynamically hidden or shown i.e. properties of ‘Rental details’ group. Now in the visible property section, define the condition that triggers the fields to be dynamically shown or hidden. So, I have set the condition that when ‘Contract Type’ equals ‘Rental Contract’ then only ‘Rental details’ group should be visible i.e. I have written the condition as below:  “Contract Type”=”Contract Type”::”Rental Contract” Below are the screenshots of my page: The above shows the three options available for contract type. So if Contract type ‘Lease contract for Non-Uber drivers’ or ‘Lease contract for Uber drivers’ is selected then the ‘Rental details’ group along the fields it contains are hidden. The above screenshot shows that only if ‘Rental Contract’ is selected as ‘Contract Type’, only then the Rental details group and the fields it contains becomes visible.

Share Story :

Deploying SSRS Reports on SQL Server

Posted On July 25, 2017 by Admin Posted in

In this blog article, I will explain you how to deploy the  SSRS Report on SQL Server. Now you have your report done and it’s time to get them on your reporting server from visual Studio. Within Visual Studio, you can deploy your any individual report or entire project full of reports. In Solution Explorer -> right-click on your project -> Properties. Enter the Target Server URL. If you don’t know what your TargetServerURL is, Start instance of Reporting Services Configuration Manager  -> click the Web Service URL tab. The URL you need is in the Report Server Web Service URLs section. Return to the Property Pages box, enter the above URL as the TargetServerURL, and click OK. Now you can right-click on either your project or any single report and click Deploy. Now we have to verify that our report made it to the server and that we can execute them. To get the URL for previewing the reports, open the Reporting Services Configuration Manager, click the Report Manager URL tab and copy the Report Manager URL. Open that URL using Internet Explorer with administration permission(Right click on internet explorer -> run as administrator). Navigate to the SSSR Reports folder, click on your report name, and you should be able to execute it right there in the browser.

Share Story :

AX Error: “Update Patch of AX unable to find a record” in TIBCO Cloud Integration

Posted On July 24, 2017 by Admin Posted in

In this article, we see AX hotfix deployed by Scribe which resolves the issue for Update Patch in Dynamics AX Connector. Error Details: We have Integration build between Dynamics 365 and Dynamics AX. One of the Integration package integrates CustomerPostalAddress from AX to Address in Dynamics 365. In this package, we wanted to store AddressNumber of Dynamics 365 back in Dynamics AX. So, for updating the CustomerPostalAddress with AddressNumber we used UpdatePatch with AddresslocationId as the matching criteria. Unfortunately, we were getting an error as “Error in calling Operation Update Patch: Operation returned no results. Label: Update Patch CustomerPostalAddresses, Name: CustomerPostalAddressesUpdatePatch” Strangely, we could Query, Fetch and lookup using the same criteria of AddresslocationId to retrieve records from CustomerPostalAddress. Solution: Scribe recently deployed an AX hotfix which resolved this issue. Turns out, if any DateTime field is a primary key for a entity then in matching criteria we have pass all the primary keys. Here, we are using CustomerPostalAddress entity. Primary fields of this entity are: AddressLocationId (String) dataAreaId (String) Effective (DateTime) CustomerLegalEntityId (String) CustomerAccountNumber (String) So, in the Update Patch for CustomerPostalAddress we have to pass all these 5 fields for it successfully run the Update Operation.

Share Story :

NAV Error: “Resource not found” in TIBCO Cloud Integration

Introduction: In this article, we will see how to resolve the below error while creating/quering records from NAV. Error Details: Error in calling Operation Query (Lookup Block): Operation failed. Label: Lookup CFSCar, Name: CFSCarLookup, Message: The following error has occurred in the Dynamics NAV Connector: Error: NotFound status code = 404. Resource not found for the segment ‘CFSCar’. Scenario: We have a scenario where we are building Integration Process between Microsoft Dynamics 365 (CRM) and NAV 2017. For NAV entities to be visible in Scribe Online, we have to create a Web Service in NAV for that entity. For more Information, you can check our blog article here. So, we had created a Web Service for Item entity i.e. here Items are Car details so the name ‘CFSCar’ in NAV. The ‘CFSCar’ Entity was visible in Scribe Online. But, recently we were getting “Resource not found” error for ‘CFSCar’ entity. So, we Reset the metadata for NAV connection in Scribe and the entity ‘CFSCar’ was not visible anymore. Troubleshooting: We checked the OData URL for entity ‘CFSCar’. We were getting the below error. Reading the above error, we couldn’t pin point the exact error, so we checked the SOAP Url as well. In the SOAP URL for ‘CFSCar’ entity, proper error was displayed. Error details: Naming Conflict within the “Car Status” object. Fields “Rental/Ops Hold” and Rental / Ops Hold” are both transferred to “Rental_Ops_Hold”. Please find new a name for one of those fields! Turns out there was two Status of same name which was causing an issue. Solution: Once we deleted the duplicate status the error was resolved.

Share Story :

Using Shared Mailbox in Office 365

Now often, you want to have a common mail address for everyone within a team to monitor and interact through like info@domain.com or support@domain.com Office 365 provides this capability with something called as Shared Mailbox. Features of Shared Mailbox Shared Mailbox doesn’t need an Exchange license. Shared Mailbox doesn’t have its own credentials. Users add this mailbox to theirs and use their own credentials to access it. Shared Calendar is available in a Shared Mailbox where everyone can see who is available when Setting up Shared Mailbox You’ll need to be an administrator in Office 365 to be able to create a Shared Mailbox. Navigate to Office 365 Admin Center and find Shared Mailboxes options under Groups. Click on Add a mailbox I’ll call it Sales@domain.com, for example. And click Add. I selected both the users seen in above step to add to the Shared Mailbox. Those members are seen on the detail pane of the selected Shared Mailbox as shown below Shared mailbox gets created within moments! Adding Users to the Shared Mailbox Only users who have an Exchange Online license can be added to Shared Mailboxes. Click on the mailbox and then on Edit in Members area to add O365 users to the mailbox as shown below Click on +Add Members to add users to the mailbox. You’ll find all the members who already have an Exchange Online license are eligible for adding to the shared mailbox. I selected both the users seen in above step to add to the Shared Mailbox. Those members are seen on the detail pane of the selected Shared Mailbox as shown below Adding Shared Mailbox to Outlook I will show the OWA example in this blog to show how to add the shared mailbox to the user’s Outlook Let’s assume we have the mailbox pwagh@cft79.onmicrosoft.com and we want to add the shared mailbox sales@cft79.onmicrosoft.com to pwagh’s mailbox. In OWA, right click on the root folder of the mailbox and click on Add shared folder Start typing the name of the Shared Mailbox and it should auto-populate the same for you. Select the Shared Mailbox and click Add. The mailbox should then appear in your OWA. Note: It takes a few minutes until the Shared Mailbox is accessible from your mailbox after adding it Hope this was helpful.

Share Story :

Exporting record details to excel using Excel Buffer in Microsoft Dynamics NAV 2017

Introduction In this article, the selected record details by the user are exported to excel using Excel Buffer. The requirement was such that Purchase Request is sent to the Vendors to enter the Unit cost of each Purchase Items. These details are sent to the vendors in an excel sheet. After the Unit cost is entered the excel sheet is imported again in the Dynamics NAV. Pre-requisites: Microsoft Dynamics NAV 2017 Steps: 1.Create a report and Data link between the records. 2. Below is the screenshot of the Data Item Link 3. In the globals (Ctrl+G), define the excel buffer table (no 370) to create excel sheet 4. Define the function MakeExcelDataHeader to create the header of the excel sheet and MakeExcelDataBody for the Body Lines. 5. Create a Boolean variable Print to Excel and insert it in the request page. If true then call the function CreateExcelBook. 6. On the PreDataItem Call the function MakeDataExcelHeader and OnAfterGetRecords call the function MakeDataBody 7. Using Excel Buffer table code as below in the functions 8. In the Page, create an action button to run the report. 9. In the page, select the record and click on the Export to Excel button 10. Click on OK 11. This call the report and fetches the data records in an excel sheet. This sheet is then sent to the vendor to enter the unit cost of the respective item. Conclusion: Thus using excel buffer record we can export records from Microsoft Dynamics NAV to Excel sheets.  

Share Story :

Item Charges Setup in Dynamics NAV

One of the most popular and widely accepted ERP systems which is popular in both small and big businesses is the Microsoft dynamics nav integration. The reason for its popularity and wide acceptance is its user-friendly interface and simple installation process. Dynamics NAV customers are missing out on the real benefits of upgrading to Dynamics NAV in today’s cloud-based environment. If you upgrade Dynamics NAV, you will be taking advantage of improved functionality, new features, and enhanced capabilities, you can boost productivity, reduce costs, and improve customer service. Microsoft is continually looking at ways to improvise the Enterprise Resource Planning Systems. Using Microsoft Dynamics NAV Inventory Management, companies can do tasks such as setting up alternative vendors, check on inventory assembly management, and get the required analysis report with ease. Introduction: The item charge functionality in Dynamics NAV gives you the option to include additional costs such as freight, insurance, fuel charges, etc. in the unit cost or unit price of an item transaction. Item charges setup is part of the general Finance setup. Companies can set up different item charge numbers to distinguish types of charges and improve cost and sales statistics. Set up: Path : Financial Management > Inventory > Setup Or Enter “item charges” in the Search box, and then select the related link. Item charge must have a general product posting group and a VAT product posting group. This combination of posting groups determines the general ledger account to which the item charge is posted. Once Item charges has been setup then you can select it on purchase ad sales document line Conclusion : Item charges are an ideal way to record item-related financial transactions without affecting inventory quantities. A company can use item charges in the purchase and sales processes to improve the accuracy of cost and sales information, and contribute to improved decision making.

Share Story :

Generic Type Bookable Resource on Schedule Board in D365 Field Service

Introduction: This blog explains how to filter Generic Type Bookable Resource on Schedule Board. Pre-requisite: Latest Field Service Solution of D365. Procedure: 1. Open Schedule Board, Field Service → Schedule Board.   As highlighted below there is no option to select Generic Type Bookable Resource in Filter Section. 2. Click Options → Selected Resources 3. Select Generic in Resource Types drop down as shown below. 4. Select Bookable Resources as per need. 5. Bookable Resource are shown in Schedule Board of type Generic. Conclusion: This blog explains how to filter Generic Type Bookable Resource on Schedule Board.  

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 :

SEARCH BLOGS:

FOLLOW CLOUDFRONTS BLOG :


Secured By miniOrange