locked
Disable/Enable New button on filtered lookup. RRS feed

Answers

All replies

    • Marked as answer by David Withers Wednesday, April 7, 2010 6:15 PM
    Wednesday, April 7, 2010 6:01 PM
    Moderator
  • Considering i have 50 lookups that need the new button and only a handfull that dont.... i think this helps a ton!!!!

    Thanks again!!!!!


    Withers
    Wednesday, April 7, 2010 6:17 PM
  • I modified it slightly:

    //disble lookup buttons
    //
    RemoveLookupButtons = function (LookUpId, ShowProp) {
        var aLookup = LookUpId;
        aLookup.AddParam("ShowNewButton", "0");
        aLookup.showproperty = false;
        if (ShowProp == 'N') {
            aLookup.AddParam("ShowPropButton", "0");
            aLookup.showproperty = false;
        }
    }
    RemoveLookupButtons(crmForm.all.new_approvedpricingid, 'Y');

    Withers
    Wednesday, April 7, 2010 6:58 PM
  • An interesting hack of the new button is overriding it to provide a "parent" context for the new record.  This is nice for establishing an automatic relationship between the "New" record and the record that contains the Lookup (this functionality was also discovered/blogged by Adi Katz):

    lookupField.AddParam("ShowNewButton", 1);
    lookupField.AddParam("parentId", parentGuid);
    lookupField.AddParam("parentType", parentOTC);

    Where:

    parentGuid is a string representing the GUID of the "parent" record

    parentOTC is the Object Type Code of the "parent" record


    Dave Berry
    Wednesday, April 7, 2010 8:00 PM
    Moderator
  • well that changes everything!!!!!!

    that is the whole reason to disable the new button most  of the time.


    Withers
    Wednesday, April 7, 2010 11:08 PM