Dynamics CRM Archives - Page 7 of 16 - - Page 7

Category Archives: Dynamics CRM

C# Code to retrieve lookup value id from target entity in D365 CE.

Let us consider below example as use case We have Plugin that triggers on Update of Contact Table and wanted to retrieve Customer related to Contacts. Customer is Lookup field on Contact Table. Hence here our target entity is Contact. Code – Entity targetEntity = (Entity)context.InputParameters[“Target”];   Guid ContactId = targetEntity.Id; Using the above code we get the target entity Contact Guid and now we need to retrieve Customer lookup from the target Entity. var cols = new ColumnSet(new String[] { “parentcustomerid” }); Since we only want Customer lookup from Contact hence retrieving only Customer and you can retrieve columns as per your requirement. Entity parententity = service.Retrieve(“contact”, targetEntity.Id, cols); We have stored Retrieved values in parententity. Guid ParentAccount = ((EntityReference)parententity.Attributes[“parentcustomerid”]).Id; And in above step we get the Guid of Customer. Conclusion – This was simple example of accounts and Contacts, you can use the above code(specify the schema name of lookup field you want to retrieve) to retrieve any lookups from your target entity based on your requirement Hope this helps !

Share Story :

[Resolved]You don’t have permission to view files in this location, Contact your Microsoft team owner or SharePoint administrator for access.

We added a new User in CRM, User has the System Administrator role but still were getting the below error. You do not have permission to view files in this location, Contact your Microsoft team owner or SharePoint administrator for access.  We did check User’s SharePoint access and, but it did not work. Solution – In User entity [OOB], there is OOB field called as “Sharepointemailaddress”.  Add same email id of User -> save the record and it will be resolved. Hope this helps!

Share Story :

Capture Case Resolution data before reopening case using C#

Introduction: When we reactivate cases, the old case resolution record is set as cancelled and a new case resolution record is created, before you re open the case, you can actually store case resolution data, which you can later use when you re-close the case. Solution: Below is the code to get case resolution data   Code below is to close case again with data saved as per above string Note: Case Resolution entity is not visible through advance find, for testing purpose, you can filter activities by activity type= case resolution and regarding as your case Id.

Share Story :

Disable field on change of tab in D365 CE

Use case – Our requirement is to enable field description field on invoice line form on clicking of tab General. Let’s see how we can achieve this Solution – Step 1 – Create web resource with below function- var invoiceLineCustomization = {     unlockField : function(executionContext)     {         var formContext = executionContext.getFormContext();             formContext.getControl(“description”).setDisabled(false);     }, } Step 2: Add this web resource on tab property event TabStateChange and try. (path to go to event tab – Click on tab -> change properties -> event) Output – Hope this helps !

Share Story :

Get Time in Hours and Minutes from a Date Field in CRM using JavaScript.

D365 gives a functionality to create a Date and Time field where in you can provide the user to select the date or both date and time. But what if you just need the time in Hour and Minutes format from the selected date in the Date field, This can be achieved using a JavaScript. In this blog lets see how we can get the time entered in the date and time field and format it in hours and minutes format. I have created a field in CRM with field type Date and time. Here is how it looks Using the JavaScript “Date” functions you can get the Time entered in the date and time field as shown below. This code gets the date and time (hours and minutes) selected in the date field and will format the hour and minutes in the format “HH:MM“. Hour – (getHour()) Minutes – (getMinutes()) Output – Note : You can also add the AM / PM to the time string I have not added it in my time string “strTime” but have stored the value of it in “ampm“. Hope this helps !

Share Story :

Get Month | Day | Year from a Date field in CRM using JavaScript.

D365 gives a functionality to create a Date and Time field where in you can provide the user to select the date or both date and time. But what if you need just the month from the selected date in the date field or say the date or year from the selected date in the date field, This can be achieved using a JavaScript. In this blog lets see how we can split or get the Month | Day | Year from a selected date in the CRM Date and time type field. I have created a field in CRM with field type Date and time. Here is how it looks Using the JavaScript “Date” functions you can get the Month | Day | Year and Time of the entered date as shown in the below script. This code gets the date selected in the date field and splits the date into Month – (getMonth()) Note : January – December is (0-11) hence add 1 so make it (1-12). Day – (getDate()) Year – (getFullYear()) This code gives the month date and date in 2 digit format i.e. if the date is a single digit say 9 it will give it as 09. You can further use this according to your requirement either to change the date format or for many other date related customizations. Hope this helps !

Share Story :

[Quick Tip] Get SubGrid View Id using Primary Control or Selected Control for Ribbon button’s enable rule in Dynamics 365 CRM.

Use case: I have two entity Awards and Awards category. We have SubGrid on the Awards entity form for Category with Custom Ribbon button. We want to have the button should be visible on specific view only and below are steps to do so. Step 1: Configure the Ribbon Button Create a Ribbon Button, create a command and enable rule. Added enable to Command and command to ribbon button. To enable rule, create a custom rule and pass the JavaScript and parameter. Step 2: Get View id based on the CRM parameter: Now, Get Subgrid view id by passing the CRM parameter in the custom rule. When CRM parameter is Primary Control When CRM parameter is Selected Control Step 3: Write script for Enable Rule for Custom Ribbon Button. We will write a script that will enable or disable the Ribbon based on the view ID using the above code based on the passed parameter. Result: I have written the enable rule that Button should be visible only on the Active Award Category view: Result View of Current View that we get from the Controls in Web Browser Console App Full Code:

Share Story :

Disable field in Business Process Flow in D365 CE using JavaScript

Use case – Our requirement is to mark field Purchase time Frame disabled in Business process flow on change of disable field(custom field) on opportunity form. Let’s see how we can achieve this Solution – Step 1 – Create web resource with below function- Add header_process before schema name of field. Here schema name of purchase time frame field is purchasetimeframe. And after adding header_process_purchasetimeframe var opportunityCustomization = {     //opportunityCustomization.disableField     disableField : function(executionContext)     {         var formContext = executionContext.getFormContext();         var disable = formContext.getAttribute(“cf_disable”).getValue();         if (disable == true)         {             formContext.getControl(“header_process_purchasetimeframe”).setDisabled(true);         }     } } Step 2: Add this web resource on form load, on Save and on change of the field. And try Output – Hope this helps !

Share Story :

Document Location Merge Duplicate

Introduction: If you have duplicate records, you end up merging the records. What happens to the documents that are present on these records. Solution: We have two Contacts, one with Word “My doc” attachment and other with Word “Test” attachment. When we merge the two records and select C 1 as master record. The record c2 will be set as Inactive and the master record will have two document locations. That is how merge works for Documents. Hope this was helpful!

Share Story :

D365 CRM Data Import Pointers

Introduction: Data Import is an integral part of any Migration or new enviornment. CRM allows us to use Data Management>> Data Import wizard to easily import data from Excel files. Text data is easily imported but for data that is Lookup or Multi Select Option Set, users might face issues. This blog will guide as to how we import Data of different types. Lookup: This type of record actually relates to other entity. We need to first assure that the related record is already in system. Example- If we are importing Account with Primary Contact lookup, we need to be sure that the Contact File is already imported and data is present in CRM. Excel file should have same name that we have for existing record, so that it maps to the correct record. In case where we have deadlock in lookup, like Account has Contact and Contact has Account Lookup, we have to import one file without lookup and then update same with lookup. To be clear we need to upload Account without primary contact, then import Contact with Account and then update Account file with Contact. Multiselect Option Set : To import records with multi-select option set field, we would need to pass the option set labels with semicolon “;” as the separator. We need to take care that none of the labels are misspelled. Date: To upload dates, please check the data format in settings and take care that your Excel data is in same format. Other points: While importing data, Duplicate detection rules might cause records to fail, we need to unpublish, rules that do not satisfy our requirements. Also, It is advised to upload clean data and what better than using highlight duplicate and remove duplicate functionality of Excel. This is all in case of new records, in case you want to update records, download the static worksheet of records from Advance find, make changes and upload the exact same updated file, the data import wizard in this case will not ask for mapping, if it does recheck your steps performed.

Share Story :

SEARCH BLOGS:

FOLLOW CLOUDFRONTS BLOG :


Secured By miniOrange