Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 46379

Unable to clear lookup on Change with Javascript

$
0
0

Hi all,

I have a lookup field which is filtered by an optionset using this function :

function preFilterLookup() {
    Xrm.Page.getControl("lookupAttribute").addPreSearch(function () {
        addLookupFilter();
    });
}

function addLookupFilter() {

    var optionSet= Xrm.Page.getAttribute("optionSetAttribute").getValue();

    if (optionSet!= null) {

        fetchXml = "<filter type='and'><condition attribute='optionSetAttribute' operator='eq' value='" + optionSet+ "' /></filter>";
        Xrm.Page.getControl("lookupAttribute").addCustomFilter(fetchXml);

I wanted to have it so that if we change the option Set then the look up is emptied so that the user can choose from a new set of values. I did it with :

function optionSet_onChange() {
    var lookUp= Xrm.Page.getAttribute("lookupAttribute");
    if (lookUp!= null) {
        lookUp.setValue(null);
    }

However the field is never reset to null. The weirdest part is that it did work a few times at first but since then nothing.

Do any of you have any idea how that could of happened ?

Cheers

Simon


Viewing all articles
Browse latest Browse all 46379

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>