I have a lookup field on my form and I want to use a status field (custom) to use as the custom filter. My code looks like this:
function preFilterLookupRMA() {
Xrm.Page.getControl("lena_dlp_sn").addPreSearch(function () {addLookupFilterRMA();});
}
function addLookupFilterRMA() {
fetchXml = "<filter type='and'><condition attribute='lena_dlp_statusid' operator='eq' value='935240004' /></filter>";
Xrm.Page.getControl("lena_dlp_sn").addCustomFilter(fetchXml);
}
The function preFilterLookupRMA is called onLoad. My issue is the "value" parameter in the fetchXML. The value entered is the one assigned to that Option in the Option Set that I created, but when this code is run it returns 0 records. I know that there are records that match my intended criteria. The status field is for the lookup record, not the record the form is on.
I have also tried adding the Option text, but it gives an error since this field is looking for a numeric value.
How do I get the proper value of the Option Set so that this filter only gives me the records I want?