Hello folks!
On my Account form I have a new Sub Grid that I created which displays Opportunities.
Opportunities have two fields, 1) Account (out of the box field) 2) Prospect (custom account lookup field named 'new_prospectid')
I want to filter the displayed Opportunities to only show Opportunities where Prospect = the current Account open
This is the standard SDK code I have been working with, the Sub Grid however won't filter the Opportunities, i.e. I'm seeing all Opportunities. The code is called from the Form.OnLoad event.
function DisplaySubGrid() { var Sdk = window.Sdk || {}; Sdk.filterOpportunities = function () { //Only show opportunities with the prospect set as the current account var customerAccountFilter = "<filter type='and'><condition attribute='new_prospectid' operator='eq' value='" + Xrm.Page.getAttribute('accountid').getValue() + "'/></filter>"; Xrm.Page.getControl("new_prospectid").addCustomFilter(customerAccountFilter, "opportunity"); } //set 'Sdk.setParentAccountIdFilter' in the Opportunity form onload event handler Sdk.setParentAccountIdFilter = function () { Xrm.Page.getControl("new_prospectid").addPreSearch(Sdk.filterOpportunities); } }