Posts

Filter subgrid using javascript in Dynamics 365

Image
Filter subgrid using javascript in Dynamics 365.  Below is JS code which we need to call on + new button of subgrid Add the below JS using ribbon bench + new button of subgrid Step 1 : Create your function e.g  FilterPartnerInPromotion() Step 2 :  Call the function on click on + button of subgrid. Follow the below image Register your webresource and function on ribbon command. Use case : We have to filter partner grid (Custom Entity ) based on certain feild (Distrubution channel) on promotion (Custom entity ) form Modify the filter and schema based on your condition. Focus on red highlighted lines fetch xml and layout xml you can put based on your use case. // to filter promotion function FilterPartnerInPromotion() { debugger; try { var entityName = Xrm.Page.data.entity.getEntityName(); if (entityName == "zh_promotion") {  // to check filter is only on this entity you can remove var viewId = "{72A70595-C721-4400-8D9B-1612E2A570DE}&