How to display more than three columns in Dynamics 365 lookup view.

We know that we can display multiple column in the dynamics 365 lookup view but there is a limitation that you can only display maximum three column in the lookup view, though we can add multiple columns in the lookup view but you can see only first three columns in the lookup view. This is a limitation in Dynamics 365, Microsoft mentioned here.

https://docs.microsoft.com/en-us/dynamics365/customer-engagement/customize/choose-and-configure-columns

Now how to display more than three column value in the lookup. You might be thinking to create a field where if we can store concatenating multiple fields value with some separator and add the field in the lookup view. So now to do this you may need to go for workflow /plugin/JS which is additional work.

Why not we go for calculated field where we can concatenate multiple fields and add the calculated field in the lookup view. I did the same with calculated fields and now I can display more than one field value in my lookup view.

I have created a calculated field (type single line text) in account entity and concatenate few fields with “/” separator which I want to display in the lookup view.

My calculated fields working  fine, see below screenshot.




Now I have added the calculated field in the Account lookup view and do save and publish all customization.

 



 

Now I can see more than three column value in the lookup view.

 

I have also answered similar question in Dynamics CRM Community

 

Hope this helps 😊.

Advertisements

Solution Patch in Microsoft Dynamics 365

Introduction

Solution patching is a very powerful feature in Microsoft Dynamics 365 when you are working on different phases for a project or working with multiple solution. In my experience, one of the complex things is to managing solution in Dynamics 365. Many people are struggling with managing their managed/unmanaged solution now days, believe me your life will become easy when you use Solution Patching.

Why Solution Patch is Required?

You may know there is two type of solution called managed and unmanaged. I am not going to details about those. In development environment we usually working on unmanaged solution and when we are moving the solution to another environment most of the time we are making it managed solution.

The problem starts here, every time you must deploy complete managed solution (For any changes of existing managed solution component) in your target instance (UAT), which means by unknowingly/unintentionally you are overwriting changes to your target instance(UAT). This creates problem when many people working on the same solution. You might not aware who did what, moreover you may need to do complete test after deployment, which need additional effort and time.

How do you manage solution Patch?

Before moving the actual topic, I would like to talk about versioning of the solution. Microsoft Dynamics 365 provides solution version number format which looks like 1.0.0.0. Where last two numbers define as minor version, and the first two numbers talks about major version. So how you can apply version number using patch?

In the Dynamics 365 there are two button “Clone To Patch” and “Clone Solution”. When you will do “Clone To Patch” that means you are creating minor version from your main solution which means you are creating a patch where you are going to change future task . Here you can see you can only change last two numbers for “Clone To Patch”.

2019-02-28_11-46-13

Let’s assume you have an unmanaged solution called “Solution M” (version 1.0.0.0) which delivered in UAT as managed solution. Now you are moving to project next phase or you got some change request and now you must create a patch on top of unmanaged solution. Assume that you create solution “Patch A “with version 1.0.1.0 and “Patch B” with Version 1.0.2.0.

You can create number of patches as per your requirement and deploy only patches to the target instance. So in your DEV environment you have below solution.

  1. “Solution M” (Version:    1.0.0.0) [Main unmanaged in DEV]
  2. “Patch A” (Version: 1.0.1.0) [Unmanaged]
  3. “Patch B” (Version: 1.0.2.0) [Unmanaged]

And in your UAT instance you have all solution like above and those are managed.

  1. “Solution M” (Version: 1.0.0.0) [Main managed solution which delivered first to UAT]
  2. “Patch A” (Version: 1.0.1.0) [managed]
  3. “Patch B” (Version: 1.0.2.0) [managed]

You might be thinking it’s difficult to manage multiple solution again using solution patching. No it’s not like that and that’s why you have a button “Clone Solutions”.

You should always do “Clone Solution” by selecting parent solution (Here our parent solutions “Solution M”) from where you have created the patches. So once you do “Clone solution” by selecting the parent solution (Solution M) all the patches will be merged with a new version of Solution. Let’s give the version no of new cloned solutions 2.0.0.0. Look below screenshot when you do “Clone Solution”, which means you are creating major version by merging all the patches and creating only one solution.

2019-02-28_11-46-51

You will see only one solution in you DEV environment after doing “Clone Solution”. All solution will be automatically merged; you don’t need to manually handle them.

  1. “Solution M” (Version:  2.0.0.0) [Main unmanaged in DEV]

Now you might be thinking what happen when you deploy the cloned solution in the target instance (UAT). When you deploy new cloned Managed solution its automatically merge all the existing managed solution and you can see only one solution in your target instance. Make sure you choose following options at the time of import. [For major version/cloned solutions, this may be including deletion existing fields, entity from the solution which will apply to target instance.].

  1. Stage for Upgrade.
  2. Overwrite Customization.

010716_0733_SolutionPat13

Once solution import done don’t forget to do “Apply Solution Upgrade”. Once you click on apply solution upgrade which means you want to upgrade the solution as it is like DEV which is will also apply deletion of any component from the existing solution in your Target instance. This is one of the beauty part of the Solution cloning. Ideally if you don’t use Solution Clone, you will get the dependency error for importing managed solution. So now you don’t need to worry about that.

2019-03-01_10-41-54

After doing “Apply Solution Upgrade”, don’t forget to do “Publish all customization”. You will see in your target instance (UAT), only one solution will be there.

  1. “Solution M” (Version:  2.0.0.0) [Managed solution in target instance (UAT ) after deploying cloned solution.]

Hope this helps J.

Workaround of Dynamics 365 file download issue in Chrome browser

Recently there is an issue happening in Chrome browser latest update (Version 72.0) while downloading any file from Microsoft Dynamics 365. File is always downloading with name inside single quotes.Many people are raising this issue in the community.

2019-02-22_13-17-02

2019-02-22_13-10-36

 

2019-02-22_14-44-05

 

This is a known issue and  Microsoft is working on this , hopefully it will resolve soon. Workaround would be rename (Remove single quotes ) the file after download to open with proper format. 

Also you can download the chrome extension for temporary fix.

 

Hope this helps :).

 

 

 

 

 

 

 

Auto Save Feature in Dynamics 365 CE.

This is kind of old feature which was released in Dynamics CRM 2013. You may know its tells everything when we say Auto-Save. However, we must know some of the key points associated with Auto Save.

Key Points about Auto Save

  • You can enable auto to save by going to Settings ->Administrator –> System Settings -> Under General Tab -> Select Yes.

2019-02-15_12-53-21

  • Auto Save feature works only on update form.
  • Auto Save feature does not work on create form.
  • Whenever you set any value of the field using JavaScript or manually or business rules you can see in the bottom right corner of the form save icon with text “Unsaved Changes” if you removed the cursor from the field, once 30 seconds /default time over form will automatically save.

2019-02-15_12-50-51

  • Whenever you navigate to another form, if you change any fields value in the form. You cannot see below popup to say that “Your changes have not been saved”, which means form always save automatically if any changes you did in the form. In other words, when you navigate to another page, Auto Save is trigger immediately. No matter about time 30 seconds over or not.

2019-02-15_12-57-55

  • Auto Save trigger after 30 seconds of remove cursor from the field.
  • Auto Save does not start time count when your cursor inside the field. You must move the cursor from the field to start time count.
  • Once Auto Save enabled you cannot see the “SAVE” button in the top ribbon of any update form.You can use short cut CTRL+ S to save the forms.

2019-02-15_13-11-25

Hope this helps.

Validate different entity fields value using workflow

Sometimes we may have requirement to validate some different entity fields while creating or updating record. This can be done by using plugin or JS API code, but how to do that without writing any code or using OOB workflow.

Yes, this is true that its depends on the scenario and not all scenario you cannot validate different entity records using workflow. Now question is when and which scenario you can validate different entity record using OOB workflow.

Let’s assume I have two entities one is Category and second one is Subcategory. The relation between Category and Subcategory having 1: N, which means a Category can have multiple Subcategory. In other words, in the subcategory we will have a lookup field of category and in the Category entity we would have SubGrid of Subcategory records. In short Category is a parent entity and subcategory is a child entity.

So in that case you can validate parent entity record while creating child record. And it’s not possible to validate child entity record while creating parent record using workflow. This is because in the workflow you will not get the lookup reference.

Scenario:

In Category entity I have field called “categoryname” and in the “Subcategory” entity I have a field called “subcategoryname”. I want to restrict creation of SubCategory entity record if the “subcategoryname” name matches with “categoryname”.

Here are the steps how to do that –

Step: Create a workflow create event and of “SubCategory” entity.

1

Step 2: In the condition I put subcategoryname = Choose the related lookup of the Category entity and under that select “categoryname”.

2

Here is the result –

3

Hope this helps.

Retrieve User assigned Roles with user information using Query Expression , C# in Dynamics 365.

Sometimes we may need to retrieve login user security roles with user details using Query Expression. Here is simple Query Expression to retrieve user information with all assigned security roles by user GUID.

                // Pass user GUID
                Guid userid = new Guid("55A0BCC3-6DC2-4B75-B00F-200B2C7A8EF6");
                QueryExpression qe = new QueryExpression("systemuserroles");
                qe.ColumnSet.AddColumns("systemuserid");
                qe.Criteria.AddCondition("systemuserid", ConditionOperator.Equal, userid);

                LinkEntity link1 = qe.AddLink("systemuser", "systemuserid", "systemuserid", JoinOperator.Inner);
                link1.Columns.AddColumns("fullname", "internalemailaddress");
                LinkEntity link = qe.AddLink("role", "roleid", "roleid", JoinOperator.Inner);
                link.Columns.AddColumns("roleid", "name");
                EntityCollection results = organizationService.RetrieveMultiple(qe);
                foreach (Entity Userrole in results.Entities)
                {
                    if (Userrole.Attributes.Contains("systemuser1.fullname"))
                    {
                        Console.WriteLine("User Name : - " + (Userrole.Attributes["systemuser1.fullname"] as AliasedValue).Value.ToString());
                    }
                    if (Userrole.Attributes.Contains("systemuser1.internalemailaddress"))
                    {
                        Console.WriteLine("Email : - " + (Userrole.Attributes["systemuser1.internalemailaddress"] as AliasedValue).Value.ToString());
                    }
                    if (Userrole.Attributes.Contains("role2.roleid"))
                    {
                        Console.WriteLine("RoleId : - " + (Userrole.Attributes["role2.roleid"] as AliasedValue).Value.ToString());
                    }
                    if (Userrole.Attributes.Contains("role2.name"))
                    {
                        Console.WriteLine("Role Name : - " + (Userrole.Attributes["role2.name"] as AliasedValue).Value.ToString());
                    }

                }

 

Here is the results.

2019-01-26_23-29-29_roles

I have answered similar requirement here  in D365 community.

Hope this helps.

Understanding QueryExpression “Orders” in Dynamics 365

Recently I am experiencing an issue while setting “Order” of the QueryExpression with attributes name using link entity “Alias” name.

Let me give you a scenario let say you I am retrieving Account information and related primary contact information of the account. Here is my query, I am retrieving account name and primary contact first name, last name here. Here you can see I have used “primarycontact.firstname” in the order expression of the link entity. Below code give me error “primarycontact.firstname” does not exists in contact entity.

QueryExpression qe = new QueryExpression();

qe.EntityName = "account";

qe.ColumnSet = new ColumnSet();

qe.ColumnSet.Columns.Add("name");

qe.LinkEntities.Add(new LinkEntity("account", "contact", "primarycontactid", "contactid", JoinOperator.Natural));

qe.LinkEntities[0].Columns.AddColumns("firstname", "lastname");

qe.LinkEntities[0].EntityAlias = "primarycontact";

// Set Order for Child - No need entity Alias, just to add the link entity column name inside link entity order expression

OrderExpression linkentityOrder = new OrderExpression("primarycontact.firstname", OrderType.Ascending);

qe.LinkEntities[0].Orders.Add(linkentityOrder);

EntityCollection ec = organizationService.RetrieveMultiple(qe);

 

So now what should you use when you are retrieving multiple entity data with order of child entity or parent entity attributes. Now look at above query at first I am adding parent (Account) entity columns like –

qe.ColumnSet.Columns.Add("name");

 

And then I am adding columns of link entity (Contact) under link entity expression –

qe.LinkEntities[0].Columns.AddColumns("firstname", "lastname");

 

Which means we are defining columns in a query expression in two level, first for the parent entity and then the link entity level.  We don’t need to use any “Alias” name separately while setting ordering of the columns in a query expression. Simply use the name of the attributes which you set the columns under link entity.

Here you can see I have used the same name which I used at the time of adding the columns in the child entity as parent entity and this should work fine.

 

qe.LinkEntities[0].Columns.AddColumns("firstname", "lastname");

qe.LinkEntities[0].EntityAlias = "primarycontact";

// Set Order for Child - No need entity Alias, just to add the link entity column name inside link entity order expression

OrderExpression linkentityOrder = new OrderExpression("firstname", OrderType.Ascending);

 

Here is the final query which should work for you, make sure you cannot set two order expression at a time so I have commented parent “Order” expression.

 

 

QueryExpression qe = new QueryExpression();

qe.EntityName = "account";

qe.ColumnSet = new ColumnSet();

qe.ColumnSet.Columns.Add("name"); // parent entity (Account) Field

//  * Set Order for parent - No Need Alias name, only name of the attributes *

// OrderExpression ParentEntityOrder = new OrderExpression("name", OrderType.Descending);

// qe.Orders.Add(ParentEntityOrder);

qe.LinkEntities.Add(new LinkEntity("account", "contact", "primarycontactid", "contactid", JoinOperator.Natural));

qe.LinkEntities[0].Columns.AddColumns("firstname", "lastname"); //link entity ( Contact) Field

qe.LinkEntities[0].EntityAlias = "primarycontact";

// Set Order for Child - No need to use entity Alias name, just to add attributes name which you add columns inside link entity.

OrderExpression linkentityOrder = new OrderExpression("firstname", OrderType.Ascending);

qe.LinkEntities[0].Orders.Add(linkentityOrder);

EntityCollection ec = organizationService.RetrieveMultiple(qe);

 

 

In summary, you cannot use “Alias” name in the “Order” expression  of any query expression, you should set attributes name only.