Posts

Apply Custom Filter on Multi-Entity Lookup field

Image
In this blog, we are going to discuss how we can apply a custom filter on multi-entity reference lookup. There was a requirement, to restrict lookup data on From field on Email. From field has the data type of Party List which basically allows you to select a record from the users and queues table. Now, the requirement was to restrict the data in such a way where logged In user can see only the queues of which he was a member, and for the user's table only his record to be shown. As per the requirement, I have to apply two custom filters on the form field for each entity. I never did this before. So, after a lot of research and development found that the solution was too easy. We just have to apply a addCustomFilter function twice(one for each entity). like this: Now I know how I can apply the custom filter on Multi-Entity lookup. It could have done the job for me if my filter on entity was straight forward. But, In this case it wasn't solving my problem as it only works with...

Performing CRUD operations between different CRM environments

Image
In this blog, we are going to discuss how to perform CRUD operations between CRM environments. As you all might be aware, there are already existing ways to do data migrations, such as  Data Import , Kingswaysoft SSIS Package , using programs, and so on. Here we are going to perform data migration between CRM environments in a different way to import data with the same record identifier and then we are going to perform read, update, and delete operations on imported data. Prerequisite:  You must have an understanding of the  SQL queries. So, Let's Start. 1. Open  SQL 4 CDS in XrmToolBox. 2. Add connection of source and target environment. In this example target is RND and source is TEST . 3. Write a query to perform operation and execute it. CREATE: Inserting records from source environment to target environment. Here we are inserting only two columns, activityid : record identifier and subject , with a pretext of ' Imported Task: '. So, you can add the c...

Show user login details in a quickest and more flexible way

Image
You all might be aware of the CRM inbuilt  User Audit Access functionality , which shows user login access. I also proposed the same solution to my client, when he asked me about how to check user login date and time in CRM. But, he wanted a user-friendly and flexible way to access this data.  Problem with current inbuilt functionality :      1. Accessing Data                   To access the user login audit data, as a user I have to perform several steps. which is not the quickest or most convenient way. i.e.   Go to Advanced Settings >> Auditing >> Audit Summary View >> Filter Event Column with "User Access via Web".      2. No filter on User Record                     It shows the login data for all users. The filter is not available for the user record, which makes it hard ...

Create custom N to N relationship in Dynamics CRM

Image
Disclaimer:  It is recommended to use the existing OOB N: N relationship for an entity. The custom N: N relationship is only to be used for entities that do not support the N: N relationship. As the title suggests, in this blog we are going to discuss how to create a custom N: N relationship. The topic is divided into the following parts: 1. Need of custom N: N relationship. 2. Implementing custom N: N relationship. So, let's begin. 1. Need of custom N: N relationship         One day, I received a requirement to develop functionality where a user can add multiple users and contacts for appointments and phone calls, and later on, he can send notifications to selected contacts or users via mail. The approach was simple, to create an N: N relationship between appointment to user and contact and then add a subgrid on the form for each entity. But for activity entities, CRM does not allow you to create an N: N relationship.  Hence, a custom N: N relati...

Efficient way to check Logged In user's security role

Image
As a CRM developer, we all have developed functionality to check logged-in user's security roles. We used to get GUID of security role and then we have to fire a query to the server-side to get the role names. Thankfully Microsoft has slipped in an update to get the role names. Xrm.Utility.getGlobalContext().userSettings  has been updated with a new function called roles ,   which returns a collection of lookup objects containing the GUID and display name of each of the security roles assigned to the user and any security roles assigned to the team that the user is associated with. Let's take look at this with a scenario: I have to perform some functionality if the current user has  Sales Manager or Marketing Manager  role assigned to him. And here is the result: currentUserRoles object contains all the roles assigned to the logged In user and isValidUserRoles contains the result after filtering the currentUserRoles object with required roles. Click here for...

The optimized and efficient way to execute multiple API requests in one call

Image
As a developer, we have to optimize the code for better performance. Sometimes we have to make multiple API calls for different kinds of functional logic or validation on a single event, which leads to performance issues. Microsoft already has a feature called Batch Operations , but it involves a lot of code, and also the response we received is not in a JSON format. To overcome this we can use another API calling mechanism called fetch()  to execute multiple APIs. This method provides an easy, logical way to fetch resources asynchronously across the network. Let's take a look at this with an example. Here we have created an array of URLs called urls  which consist of two different API calls, the first API call to get owner details and the second API call will give the team details if a user is part of a particular team. Executing all APIs included in urls array. The responses for API will be received in the same order as an Array element. Here are the responses received:...