cancel
Showing results for 
Search instead for 
Did you mean: 

SAP MDK - Filter List picker using the value selected in the previous list picker on the same page.

swati_maste
Product and Topic Expert
Product and Topic Expert
0 Kudos
414

Hello community !

In one of my SAP MDK Projects, I have a page with 3 list pickers, Plants, Projects and Department. I am trying to filter the Department list based on the value chosen for Plant. However this dynamic filtering is not working. 

Please suggest what can be done here !

This is my page.

swati_maste_0-1727244128165.png

This is my filtering: $filter=werks eq '{{#Control:FCSetPlant/#SelectedValue}}'

swati_maste_1-1727244233184.png

 

 

View Entire Topic
Jitendra_Kansal
Product and Topic Expert
Product and Topic Expert

This is a case of cascading list picker where you want to display value in a picker based on the selection from previous picker.

You will set a rule to the OnValueChange event of the Plant List picker. Based on the selected value from the Plant List picker, this rule will set the query option and update the Target Specifier of the Department List Picker.

See this example:

 

 

export default function PlantTypeChange(context) {
    let pageProxy = context.getPageProxy();
    let plantPicker = pageProxy.getControl('SectionedTable0').getSection('SectionFormCell0').getControl('PlantLP');
    let plantTypeValue = plantPicker.getValue()[0].ReturnValue;
    let DepartmentPicker = pageProxy.getControl('SectionedTable0').getSection('SectionFormCell0').getControl('DepartmentLP');
    let specifier = DepartmentPicker.getTargetSpecifier();
    let qo = `$filter=werks eq '${plantTypeValue}'`;
    specifier.setQueryOptions(qo);
    DepartmentPicker.setTargetSpecifier(specifier);
}

 

You may additionally set the Department Picker to disable until a Plant is selected.

 

swati_maste
Product and Topic Expert
Product and Topic Expert
0 Kudos
Thank you Jitendra ! This worked