Tag Archives: Duplicate detection
Highlight Duplicate Records in Canvas PowerApps in Gallery Control
Hi All, Let’s see how to highlight duplicate records in Gallery control what works on data source or collection. In this example: I’ll be using a collection that I will highlight in 2 ways Use-case: I want to highlight duplicate ‘Project Allocation’ entries submitted. If someone has submitted a entry that has on Same Project twice needs to be highlighted. Step 1: I created a collection to replicate the scenario Step 2: Add the formula in ‘Template Fill‘ property in Gallery Control. Note: I have used random color style in my gallery, so output will be as follows For highlight only selected items in the gallery, the code will be as follows Therefore, output will be as follows Hope this helps
Define alternate keys for an entity
With the release of Microsoft 2015 Update 1 Microsoft has released lots of exciting features, one of them is alternate key. Traditionally we use CRM primary field to identify the records. All Microsoft dynamics entities has unique identifier known as GUID. This GUID is the Primary key of particular record. When we want to integrate CRM with an external data base, we might be able to add a column to the external database tables to have a reference to the unique identifier in CRM. But in various cases, it is possibility that we are not allowed to change their database to add the reference key to store the GUID. In that case we are not able to track the records in the system. With alternate keys we can now define an attribute in a CRM entity to correspond to a unique identifier (or unique combination of columns) used by the external data store. Features of Alternate Key This is used to identify the duplicate records. If there are records with the specified alternate key exists in system then it will throw an error. This avoid users to write plugin to identify the duplicate records. As duplicate detection rules allows the user to create the records even if it exists in the system. Alternate key can be combination of more than on attributes. With alternate keys, you can assure an efficient and accurate way of integrating data into Microsoft Dynamics CRM from external systems. It’s especially important in cases when an external system doesn’t store the CRM record IDs (GUIDs) that uniquely identify records Faster lookup of the records. More robust bulk data operations, especially in CRM Online Create Alternate Key To define alternate key please follow the steps: Go to Setting → Customization, open the default solution Select the entity for which you want define alternate key, in our case it is account. Select Keys and click new, which will open shown screen. You need to add column/columns which will be used as an alternate key. Save and publish. Alert As you can see in the below screen shot error reported from two different rule. One from duplciate detection rule and another one from alternate key. The main difference between these two are below In case of duplicate detection users are allowed to create new record. But in case of alternate key users are not allowed to create the record. Duplicate detection Rule Alternate Key: Attributes Valid for Alternate Key Decimal Number Whole Number Single line of text Retrieve and delete alternate keys If you need to retrieve or delete alternate keys, you can use the customization UI to do this, without writing any code. Although, the SDK provides the following two messages to programmatically retrieve and delete alternate keys. Message request class Description RetrieveEntityKeyRequest Retrieves the specified alternate key. DeleteEntityKeyRequest Deletes the specified alternate key To retrieve all the keys for an entity, use the new Keys property of EntityMetadata Class. It gets an array of keys for an entity. Using alternate keys to Update A valid Entity used for update operations includes a logical name of the entity and one of the following: A value for ID (primary key GUID value) (or) A KeyAttributeCollection with a valid set of attributes matching a defined key for the entity Programmatically: using (_orgService = new OrganizationService(connectionTarget)) { Entity account = new Entity(“account”, “accountnumber”, “SUB0001”); account[“telephone1”] = “9874563210”; account[“fax”] = “1234579856”; _orgService.Update(account); } Using alternate keys to create an Entity Reference Similarly we can use alternate key to set the entity reference field. We need to define the KeyAttributeCollection of the related entity whose lookup we want to set. We don’t need to set the GUID to relate record instead we need to set the alternate key of the related entity If the specified alternate key record does not present in the system it will through an error “A record with the specified key values does not exist in account entity” using (_orgService = new OrganizationService(connectionTarget)) { KeyAttributeCollection keys = new KeyAttributeCollection(); keys.Add(“accountnumber”, “SUB0001”); Entity contactEntity = new Entity(“contact”); contactEntity[“lastname”] = “Last Name”; contactEntity[“parentcustomerid”] = new EntityReference(“account”, keys); contactEntity[“fax”] = “9874563210”; CreateRequest req = new CreateRequest { Target = contactEntity }; _orgService.Execute(req); } Notes: For Microsoft Dynamics CRM Online organizations, this feature is available only if your organization has updated to Dynamics CRM Online 2015 Update 1. This feature is not available for Dynamics CRM (on-premises). You can define up to five different keys for an entity.