Friday, July 17, 2015

CRM 2013 Subgrid vs. (Expanded) Associated View Records. OR Recent and Associated Entity views

Sometimes you experienced when you have subgrid in your CRM Form, but when you click the ‘expand’ button to expand the view then it will redirect you to Associated View, but you found the records appear in the list are different.

to find the solution of that problem then click the below link or directly read the same content from my blog.

https://community.dynamics.com/crm/f/117/t/141127

http://missdynamicscrm.blogspot.se/2014/10/crm-2013-subgrid-vs-expanded-associated-view-records.html

I have checked this issue.

So, the issue will be happening if you have one more Opportunity to Account custom N:1 Relationship.
For example:
The standard CRM have 2 normal N1 Relationship to Account, those are Parent Account and Potential Customer.
Then, I added one more relationship with name new_account2 (Account 2) as shown here:


If you notice, in the subgrid, the Entity (Opportunity) is having setting:
(see the section inside the red-square)

So, it means that only show if the Potential Customer is the respective account, correct.
Then if you click to pop out the associated view, some of your Opportunities are gone and missed out to appear in the list.
After I checked, it was because the missed Opportunities didn't have relationship to the new relationship (in this case is new_account2 or Account 2)
So, I put more detail here.
Now, in the Account, I have two Relationship to Opportunity in the Navigation explorer.

The first one is Account to Opportunity (Custom)

The second one is Account to Opportunity (System)

And if I go to each Associated View, it will give me different result.
Okay, this is from the subgrid:

*You can see 2 Opportunities, correct.
Then, try again to see the Associated View from the Navigation.
This is from the first one (a custom relationship)

*Yes, you can only see 1 Opportunity
And this is the second one (a system relationship)

* You can see two records of opportunity and see the arrow, the new section of filter, showing it is a different associated view
And finally, from the pop out from the Recent Opportunities subgrid.

*As you can see, you can only see one (1) record, so this view, after you pop up out is referring to the custom relationship (to Account 2)
To check deeper, I try to search in the database what is the different between them, and then, yes it is actually because of the disappeared opportunity does not have relationship to Account 2:

*See the null value of Account 2, the rests are same.
And I guess, the missing Opportunities are the existing Opportunities just before you created a new custom relationship.
Because basically, for the new records, CRM will auto populate and auto-mapping all of the lookup relationship to the same entity if newly created from subgrid or associated view., in this case is Account, but not for old records (CRM Mapping behavior concept).
To ensure you and myself, I put the Account fields in to the Opportunity Form.
All of the account fields

and

And you can see that one of them doesn't have value for the Account 2, and the Opportunity with the null value will not show in the Associated View.
To check in your data, you see the missing Opportunities in your data, there are 2 records, which one them is:
"Leslie Test Lead 0627-16", and the other one I can't see since this is not in the first page.
You can try to go to Associated View and then 'Add Existing Opportunity', then add the "Leslie Test Lead 0627-16", now back to your Opportunity Form.

Then,

After that you open the form..

Now, you can see that the custom field to custom Account, in my term is Account 2, now is filled up!.
I guess this is the answer.
SO, back to your question.
How the views are populated?
The answer is:
- For the Recent Opportunities shown in the subgrid, it shows all of the related Opportunity record from the Potential Customer.
- For the Associated View pop out from the subgrid, it shows all of the related Opportunity record from the new custom relationship.
And in fact, it picks the first relationship defined in the navigation in order or in sequence (see the solution in the below section for detail)
How to solve, there are two solutions basically.
1. You fix the data, fill the value of your new custom relationship (you can use Account 2 field in the Opportunity Form) or can use by adding the Existing Opportunity through the Opportunity Associated View in the Account form, as for this example: "Leslie Test Lead 0627-16".
Or you can use Workflow or programming to auto-fill the Account 2 aligning with the Potential Customer value.
2. You can use either: Remove the Navigation of the Custom relationship
OR, just Re-Order the position of those relationship in the navigation area:

So, now this is the result after you re-order, the subgrid after you click the pop up will no longer calling the wrong associated view, instead, it will call the associated view by Potential Customer (since you put it first)

Now, your customer will see the same for subgrid or associated view after clicking the 'grid' ribbon to show the detailed associated view. And they will not frustrate again.
 

Filtered lookup for Dynamics CRM 2013

Filtered lookup is a feature which was introduced in Dynamics CRM 2011, a greatly appreciated improvement from CRM 4. Prior to this, developers had to use third party tools to achieve the same result.
So, let’s start at the very beginning

What is filtered lookup?

When you have a large data set, and you want to filter the data in a progressive manner, then you need filtered lookup. You select one criteria/field and the data is filtered as per that. Now, if you choose the next field, then this filter is further applied to the already filtered data so as to give your further specific results.
For example: You have a list of prospective sales leads, and you want to filter out prior to a campaign based on those who are doctors and those who are in the state of Massachusetts. For this data selection, you would require a filtered lookup, so that the state/ profession is first selected and then following which on choosing the second criteria, the filter should be applied to the already once filtered data.

Now, let us write the code to achieve this.
This piece of code is very small as compared to what we used to write to achieve the same result in CRM 2011.

function preFilterLookup() {
debugger;
Xrm.Page.getControl("new_linkedaccount").addPreSearch(function () {
addLookupFilter();
});
}
function addLookupFilter() {
var fetchXml = '';
Xrm.Page.getControl("new_linkedaccount").addCustomFilter(fetchXml);
}
 
NOTE:
1. addLookupFilter function can only be called from addPreSearch function that binds the function to the Lookup Control. Although, you can provide any filter condition in the fetchxml form (which you can get using advanced find) to see the filtered records.
2. Two parameters ‘filter’ and ‘entityLogicalName’ are what the addCustomFilter method will accept. If the entityLogicalName is provided (not mandatory), the filter will only be applied to that entity type, else it will be applied to all types of entities returned.

For CRM 2013 Using addCustomFilter() to get Filtered Lookup Field based on Linked Entity

Split the String values with a special character in MS Flow to convert this into Array

 Many times we have a requirement to prepare the Mailing address for some of the documents, suppose there are Address Line1, Address Line2, ...