Important! Dependent Dropdown is not working (v8.3)

Hi Team,

I'm working on Lead mini page that contains 2 lookup fields (Dropdown List): 

  • SBU : lookup field of an Object
  • Product: Page Parameter on Lead Mini Page (Lookup)

Product field is dependent on selected value in SBU field. The Product lookup should be dynamically filtered based on the selected SBU.

Current Flow/Behavior: 

  • Initially, the functionality works fine.
    For example:
    • I select SBU = 'A', and the Product dropdown shows items filtered by SBU 'A'.
  • But when I change the SBU to 'B', the Product dropdown still shows the old items from 'A'.
  • It only updates the Product list after selecting one of the old products (from 'A'), and then the list refreshes to show correct products for 'B'.

Source Code: (Handler Method)
------------------------------------------------------------------------------------------

{
            request: "crt.LoadDataRequest",
            handler: async (request, next) => {
                // Apply filter only for Product Lookup
    
                const sbu = await request.$context.ProductDS_UsrSBU_8s02jhp;
                console.log("LoadDataRequest, SBU-Detail: ", sbu)
                if (request.dataSourceName !== "PageParameters_UsrLookupParameter1_3psya3l_List_DS") {
                    return await next?.handle(request);
                }
        
                if (sbu && sbu?.value) {
                    const filter = new sdk.FilterGroup();
                    await filter.addSchemaColumnFilterWithParameter(sdk.ComparisonType.Equal, "UsrSBU", sbu.value);
        
                    // Temporary fix for Creatio DevKit SDK filter bug
                    const newFilter = Object.assign({}, filter);
                    newFilter.items = filter.items;
        
                    // ✅ Ensure request.parameters exists
                    request.parameters = request.parameters || [];
        
                    // ✅ Push filter
                    request.parameters.push({
                        type: "filter",
                        value: newFilter
                    });
                }
        
                // Fetch filtered data
                const result = await next?.handle(request);
                if (result && result.length > 0) {
                    console.log("Filtered products for SBU:", result.rows);
                }
        
                return result;
            }
        },
 
        {
            request: "crt.HandleViewModelAttributeChangeRequest",
            handler: async (request, next) => {
                // Only handle changes to SBU
                // console.log(request.attributeName);
                if (request.attributeName === "ProductDS_UsrSBU_8s02jhp" && !request.silent) {
        
                    const sbu = await request.$context.ProductDS_UsrSBU_8s02jhp;
                    console.log("SBU changed:", sbu);
                    
                   // If SBU not available, Product field is cleared & read-only. 
                    if(sbu && sbu?.value){
                        request.$context.ProductVisibilityInLeadHandOffPage = false;
                    } else{
                        request.$context.ProductVisibilityInLeadHandOffPage = true;
                    }
                    
        
                    // ✅ Clear the selected Product field when SBU changes
                    request.$context.PageParameters_UsrLookupParameter1_3psya3l = null;
                    // ✅ Manually fetch new list of filtered products
                    const loadResult = await request.$context.executeRequest({
                        type: "crt.LoadDataRequest",
                        dataSourceName: "PageParameters_UsrLookupParameter1_3psya3l_List_DS",
                        $context: request.$context
                    });
 
                    if (loadResult && loadResult.rows) {
                        // ✅ Manually assign rows to the list property
                        request.$context.PageParameters_UsrLookupParameter1_3psya3l_list = loadResult.rows;
                        console.log("Updated product list after SBU change:", loadResult.rows);
                    }                
                }
        
                return next?.handle(request);
            }
        }

-------------------------------------------------------------------------------------------

Query: When the SBU is changed, the Product lookup should:

  • Clear/reset the previously selected product.
  • Immediately reload and display products filtered by the newly selected SBU.
Like -1

Like

0 comments
Show all comments