Hi
I didn't find the exact solution what I am looking for , Just Let me elaborate the Question
I have 2 Custom entities in CRM
Customers And Events ( New_ Customers and New_Events)
In the event entity i have single line of text field Email and lookup field Email Address which is related to customers entity ,
now the events are coming from external sources and saving in CRM ,once they saved i need the Email to be populated in Email Address so that i can see the customer events in customer entity sub grid called events or is there any possibility to filter sub grid records based on Email (single line text in crm). because i created a sub grid with all records in Customer entity . Is there any possibility to do this
I need urgent help, Please help me
THANKS
*This post is locked for comments
In case you are trying to do this:
- Create a new_customer lookup field on the event entity
- On create of the event entity, run a plugin to populate that lookup
That should work just fine.
To populate the lookup, you can use a query expression:
msdn.microsoft.com/.../microsoft.xrm.sdk.query.querybyattribute.aspx
Have a look at this to see how it's done:
stackoverflow.com/.../how-to-add-a-value-to-a-lookup-field
And you'll need a plugin, of course.. There is some sample code here, but you'll need to combine it with the code from the links above:
Hi Divya,
I am not sure which is your primary field in the Customer's entity, but I doubt it's the email address.
Copying the email address to the lookup will not populate the lookup. You will need to get the referenced id of the customer record where the email address is the correct one. That can be done via web api, or if you want to do a plugin, you can write code on the Create or Update of the Event entity to update the customer lookup with the customer id (after retrieving it in your plugin code based on the email address).
Saying that, it will not resolve your issue of displaying the information in the subgrid. Subgrid contents are based on related records. If I display a subgrid of in the event entity, that means all the subgrid records will have a lookup that points to the event entity.
The only way you can filter it is by using the fetchXml/layoutXml option that I mentioned above. Since you are using CRM 2013 (based on your tag), this should work, but it might break on upgrading to Dynamics 365.
Hope this helps.
Hi Aric ,
Thanks for the reply ,
I want to filter sub grid based on email id on customer form , i tried to do in the same way
But the things not went well :(
Is there any possibility to copy the lookup field from text field using plugin code . if the email address of 2 entities matches populate the lookup field . so that automatically sub grid will filter with matching records
I need plugin code to populate the look up filed , i tried to do this js but my superior need it in plugin, so please help me to do this
Thanks
Hi Divya,
Technically you should be able to design a fetchXml to filter the subgrid results based on a particular criteria
Take a look at the following:
community.dynamics.com/.../195546
In the past, you used to get the subgrid object and assign the fetchXml and layoutXml:
subgrid.SetParameter(“layoutxml”, “<layoutxml>”);
subgrid.SetParameter(“fetchxml”, “<fetchxml>”);
subgrid.control.Refresh();
The issue that you might experience is that you cannot assign the subgrid to the document.getElement as this is unsupported. I have not recently tried this with Dynamics 365, but it is very possible that the above will still work, and instead of using
var Subgrid = document.getElementById("Name of subgrid")
you can use
var Subgrid = Xrm.Page.getControl("Name of subgrid");
Try it out, and hopefully this will help.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156