Problem with dependant lookup controls RRS feed

  • Question

  • Hello

    Let me try to explain the situation: I have a few dependant Lookup fields (lets say Country - Province - City - Street).

    • When I select a Country first, only Cities, Streets and provinces in that country are shown (dependant lookup and provinces/streets via FetchXML)
    • When I select a Province, only Cities and streets of that province are shown in the view of the City and Street lookup, Country is filled in automatically based on the province (1:N)
    • When I Select a City, the Country and Province are automatically filled based on the City and the Street Lookup shows the streets in that City.
    • When I Select a Street, Country, Province, City are filled in automatically.

    I'll try to explain my problem even my English isn't that great: A User here needs to have the functionality to keep changing those lookup values. Now the problem is, when all Lookup fields are filled in and the user selects a Province, I want to set the values of City and street on null (same for Country -> Province/City/Street on null // City -> Street on null). This means a User selects a Province -> OnChange province is called -> Clears City and Street ->  Fills in Country automatically (as mentioned before) -> On Change Country is fired -> Clears Province (not wanted), City,Street,...

    Small Example Explained:

    handleOnChangeProvinceAttribute: function () {
            var province= this.getSelectedProvince();
            //Update Country by selected Province (1:N) -> Calls OnChange Country (= handleOnChangeCountryAttribute)
            //I Need to empty Street and City
    handleOnChangeCountryAttribute: function () {
            var country= this.getSelectedCountry();
            //I Need to empty Street and City & PROVINCE :(

    I really don't know how I should handle this problem (that is why I came here). I am not a Javascript Expert either, but I need some input what the possibilities are to solve a problem like this.

    • Edited by Jochen- Wednesday, September 24, 2014 2:12 PM
    Wednesday, September 24, 2014 2:09 PM


  • Ok,

    Easy solution. Attributes had a hook to an OnChange function in the JS Code. I added a parameter to the OnChange function: clearValues. If it was undefined (user changes lookup manually/Onchange called out of CRM) , clearValues is True. In Code I called the OnChange with clearValues False. In every on change handler I checked clearValues and cleared the values if True.

    I tought, I need to call the FireOnChange method on the attributes but I can just call the function -_-.

    I am new to CRM :p

    Kind regards

    • Marked as answer by Jochen- Friday, September 26, 2014 2:29 PM
    Friday, September 26, 2014 2:29 PM