Introduction and Post References
Basically, in this post, I just want to show how to filter the N to N lookup in the subgrid in CRM Form, without even modifying the Global Subgrid Ribbon in CRM.
In my previous post: http://missdynamicscrm.blogspot.sg/2015/07/filter-nn-subgrid-in-crm-2013-using.html, I have explained about a way how to filter the N to N Subgrid Lookup, but that is needed to modify the ribbon action globally and you might need to set another condition to actually skip is you need to filter only on specific entity, but your grid will be appearing in many entities, such as:
You want to filter the Contact lookup in, if you modify the subgrid ribbon, in every contact subgrid, the filter will be applied and you might need extra code of criteria to actually limit the execution.
Good thing about that if your entity only used for single entity and you don’t need to specify is that only for subgrid or associated view, then modifying the ribbon is a better solution. however, if you want to filter only subgrid in specific entity or form, you can actually using another way.
Like you can refer to my posts:
So, in this post, basically I try to combine the ways to become one solution, to filter the N to N lookup that only applicable once the user load the form using single javascript. This is unsupported customization, but, remember, modifying the N to N view also needs unsupported customization, so yeah, to reach the requirement we have to go further for unsupported customization eventhough strongly I also not recommend.
The Code
So, I just try to combine the code becoming:
*For CRM 2013
function modifyRibbon(subgridName) { try { //to store the original function ones var originalFunctionAddNewStandard = Mscrm.GridRibbonActions.addNewFromSubGridStandard; var originalFunctionAddExistingStandard = Mscrm.GridRibbonActions.addExistingFromSubGridStandard; var originalFunctionAssociated = Mscrm.GridRibbonActions.addExistingFromSubGridAssociated; //add new standard subgrid Mscrm.GridRibbonActions.addNewFromSubGridStandard = function (gridTypeCode, parentEntityTypeCode, parentEntityId, primaryControl, gridControl) { if (gridControl != null) { if (gridControl.get_id() != subgridName) { originalFunctionAddNewStandard(gridTypeCode, parentEntityTypeCode, parentEntityId, primaryControl, gridControl); } else { originalFunctionAddNewStandard(gridTypeCode, gridControl); filterTrainerProfile(gridTypeCode, gridControl); } } } //add existing standard subgrid Mscrm.GridRibbonActions.addExistingFromSubGridStandard = function (gridTypeCode, gridControl) { if (gridControl != null) { if (gridControl.get_id() != subgridName) { originalFunctionAddExistingStandard(gridTypeCode, gridControl); } else { originalFunctionAddExistingStandard(gridTypeCode, gridControl); filterTrainerProfile(gridTypeCode, gridControl);
} } } //add associate subgrid (N:N) Mscrm.GridRibbonActions.addExistingFromSubGridAssociated = function (gridTypeCode, gridControl) { if (gridControl != null) { if (gridControl.get_id() != subgridName) { originalFunctionAssociated(gridTypeCode, gridControl); } else { originalFunctionAssociated(gridTypeCode, gridControl); filterTrainerProfile(gridTypeCode, gridControl); } } } } catch (ex) { alert(ex); } }
*For CRM 2015
function modifyRibbon(subgridName) { try { //to store the original function ones var originalFunctionAddNewStandard = Mscrm.GridCommandActions.addNewFromSubGridStandard; var originalFunctionAddExistingStandard = Mscrm.GridCommandActions.addExistingFromSubGridStandard; var originalFunctionAssociated = Mscrm.GridCommandActions.addExistingFromSubGridAssociated; //add new standard subgrid Mscrm.GridRibbonActions.addNewFromSubGridStandard = function (gridTypeCode, parentEntityTypeCode, parentEntityId, primaryControl, gridControl) { if (gridControl != null) { if (gridControl.get_id() != subgridName) { originalFunctionAddNewStandard(gridTypeCode, parentEntityTypeCode, parentEntityId, primaryControl, gridControl); } else { originalFunctionAddNewStandard(gridTypeCode, gridControl); filterTrainerProfile(gridTypeCode, gridControl); } } } //add existing standard subgrid Mscrm.GridRibbonActions.addExistingFromSubGridStandard = function (gridTypeCode, gridControl) { if (gridControl != null) { if (gridControl.get_id() != subgridName) { originalFunctionAddExistingStandard(gridTypeCode, gridControl); } else { originalFunctionAddExistingStandard(gridTypeCode, gridControl); filterTrainerProfile(gridTypeCode, gridControl);
} } } //add associate subgrid (N:N) Mscrm.GridRibbonActions.addExistingFromSubGridAssociated = function (gridTypeCode, gridControl) { if (gridControl != null) { if (gridControl.get_id() != subgridName) { originalFunctionAssociated(gridTypeCode, gridControl); } else { originalFunctionAssociated(gridTypeCode, gridControl); filterTrainerProfile(gridTypeCode, gridControl); } } } } catch (ex) { alert(ex); } }
* So the filterTrainerProfile(gridTypeCode, gridControl); is your custom function to filter the view, some as you filter and create new custom view that I also have example in my previous post:
http://missdynamicscrm.blogspot.sg/2015/07/filter-nn-subgrid-in-crm-2013-using.html.
Remember, to get the GUID of the list record to show, you can always using CRM Javascript or in CRM 2013 and above you can use smarter way that is to combine with Custom Action, since Custom Action can be called through Javascript.
http://missdynamicscrm.blogspot.sg/search?q=custom+action
Hope this helps! Jiayou!
It was really a nice article, thanks for Share this valuable information.
ReplyDeleteIf you are looking for best Oracle financials courses we provide low price of fee for online coaching
Oracle fusion Financials Training in hyderabad
Oracle Fusion Financials online Training in hyderabad
IT'S VERY USEFUL INFORMATION FOR Customize CRM Software Solution.
ReplyDeleteYou can achieve this without needing to touch the ribbon function at all if you combine the above with the method used by Kishore (which would not work on it's own for me in CRM 2013) shown here: https://kishored4.wordpress.com/2017/06/02/filter-nn-sub-grid-in-dynamics-365-without-custom-actions/
ReplyDeleteMy working filter:
function preparePreSearch() {
var myViewGuid = "{D4EDF1E1-85CD-E711-811C-005056B4252F}";
var myViewEntity = "my_entityname";
var myViewName = "My view name";
setTimeout(function() {
var subGrid_ImageButton = document.getElementById("SUBGRIDNAME_addImageButton");
subGrid_ImageButton.addEventListener("click",function() {
setTimeout(function() {
var inlineElement = document.getElementById("lookup_SUBGRIDNAME_i");
var inlineBehaviour = inlineElement.InlinePresenceLookupUIBehavior;
inlineBehaviour.AddCustomView(myViewGuid,myViewEntity,myViewName,getFetchXml(),getLayoutXml(), true);
}, 500);
});
}, 1000);
}
Very usefull information for me...
ReplyDeletePython Training
Thanks for sharing the content related to Microsoft Dynamic CRM Development Services. I want to appreciate this blog and share with my friend.
ReplyDeleteusefull information for me...
ReplyDeleteHadoop Training in Chennai
Thanks GDQ. That worked, although I had to use jQuery to find the elements. E.g.
ReplyDelete$("#SUBGRIDNAME_addImageButton").get(0)
I'm using on-premise version 1612 (8.2.2.112)
Thanks for sharing this blog it's amazing blog Microsoft crm dynamic.So in this post, basically I try to combine the ways to become one solution. customer-relationship-management.
ReplyDeleteSuch great information and useful article
ReplyDeleteCRM Software
great article thanks for shearing share
ReplyDeleteSales management software/
This comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteThanks for sharing detailed information its very useful.
ReplyDeletedynamics crm development
Nice post My sincere thanks for sharing this post Please Continue to share this post.
ReplyDeleteMicrosoft Azure Online Training
Very useful information. Thanks for sharing such a great post.
ReplyDeleteThanks for sharing.
ReplyDeleteMS Dynamics Training in Hyderabad
I found this informative and interesting blog so i think so its very useful and knowledge able.I would like to thank you for the efforts you have made in writing this article.
ReplyDeleteJava training in Bangalore | Java training in Kalyan nagar
Java training in Bangalore | Java training in Jaya nagar
Selenium training in Chennai | Selenium training institute in Chennai | Selenium course in Chennai
Selenium training in Bangalore | Selenium training institute in Bangalore | Selenium course in Bangalore
Good Post, I am a big believer in posting comments on sites to let the blog writers know that they ve added something advantageous to the world wide web.
ReplyDeleteData Science training in chennai | Best Data Science training in chennai
Data Science training in OMR | Data science training in chennai
Data Science training in chennai | Best Data science Training in Chennai
Data science training in velachery | Data Science Training in Chennai
Data science training in tambaram | Data Science training in Chennai
Data Science training in anna nagar | Data science training in Chennai
Does your blog have a contact page? I’m having problems locating it but, I’d like to shoot you an email. I’ve got some recommendations for your blog you might be interested in hearing.
ReplyDeleteBest Amazon Web Services Training in Pune | Advanced AWS Training in Pune
Advanced AWS Training in Chennai | No.1 Amazon Web Services Training in Chennai
Best Amazon Web Services Training in Chennai |Advancced AWS Training in Chennai
Best Amazon Web Services Online Training | Advanced Online Amazon Web Services Certification Course Training
Best Amazon Web Services Training in Pune | Advanced AWS Training in Pune
https://www.besanttechnologies.com/robotic-process-automation-rpa-training-in-chennai
ReplyDeleteIt is better to engaged ourselves in activities we like. I liked the post. Thanks for sharing.
ReplyDeleteJava training in Chennai | Java training institute in Chennai | Java course in Chennai
Java training in Bangalore | Java training institute in Bangalore | Java course in Bangalore
Java online training | Java Certification Online course-Gangboard
Java training in Pune
Its really an Excellent post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog. Thanks for sharing....
ReplyDeleteData science training in Bangalore | Data Science Training institute in Bangalore
Thanks for taking the time to discuss this, I feel strongly about it and love learning more on this topic.
ReplyDeleteangularjs Training in bangalore
angularjs Training in bangalore
angularjs interview questions and answers
angularjs Training in marathahalli
angularjs interview questions and answers
angularjs-Training in pune
It's interesting that many of the bloggers to helped clarify a few things for me as well as giving.Most of ideas can be nice content.The people to give them a good shake to get your point and across the command
ReplyDeleterpa training in bangalore
best rpa training in bangalore
rpa training in pune
Your posts is really helpful for me.Thanks for your wonderful post. I am very happy to read your post. It is really very helpful for us and I have gathered some important information from this blog.
ReplyDeletethanks for sharing
Breast Cancer
Popular Massage Techniques
Should Listen To
Cosmetic Surgery
Hair Loss Treatment for Men
9 Incredible Foods That Fight Cancer
How To Boost Up Your Small Business
A befuddling web diary I visit this blog, it's incredibly grand. Strangely, in this present blog's substance made motivation behind fact and sensible. The substance of information is instructive
ReplyDeleteThanks For Sharing
Types Of Obesity
Expensive Workout Equipment
Blood Pressure and Weight
Successful Journey Through Recovery
homemade laxatives
Deal With Stress
How Much Do You Really Owe Your Ex?
Can Mangosteen Cure Diabetes
You rock man.. seriously man from where do you find such info to write about.. many thanks for sharing
ReplyDeletetreatment of glaucoma
Eating Habits
Skin Care Products
At Home to Save Money
Lose that Unwanted Fat
Incorporate Wellness
Wellness More of a Priority in Your Office
This blog is really helpful to deliver updated educational affairs over internet which is really appraisable. I found one successful example of this truth through this blog. I am going to use such information now.
ReplyDeleteBest surge protector
You will need to find out the cost and other associated costs before undergoing the breast augmentation surgery.
ReplyDeleteAn author must have a vast knowledge of vocabulary. The dictionary of a writer must be full of new english vocabulary to make their work more attractive. Use of new words makes their work more valuable and graceful. Memento watch free Mexico
ReplyDeletePython Training in Pune Therefore, after you have a Python integrated with C++ code, what somebody has done is written some
ReplyDeletePython Training In Pune
I recently came across your article and have been reading along. I want to express my admiration of your writing skill and ability to make readers read from the beginning to the end.
ReplyDeletePython Training In Pune
Thank you for sharing the nice information.
ReplyDeleteNice post.
ReplyDeletejoin Python training in Pune