cancel
Showing results for 
Search instead for 
Did you mean: 

SAP MDK sap.mde.SectionObjectTable search field : get value and clean ?

0 Kudos

Hello experts,

I built a page with sap.mde.SectionObjectHeader and sap.mde.SectionObjectTable. The latter has enabled search with barcode scanner. I would like to intercept the call to the target (REST service target) triggered by the search field, to use the search literal for the call to this service and to clean the search field after that.

I wrote a rule that intercepts the call to target after search input is filled and I was able to read the search string:

let pageProxy = clientAPI.getPageProxy();

clientAPI.getSections()[1].searchString;

However, I am not able to clean it (basically to clean search string). I have two questions:

  1. Am I in the right direction reading the value from the search field (search literal)?
  2. How I can wipe out the content of the search field?

Every hint will be highly appreciated because I was not able to find anything in the documentation.

Best Regards,

Dimiter

bill_froelich
Product and Topic Expert
Product and Topic Expert
0 Kudos

Are you still trying to find a solution? Can you clarify a bit on the flow here?

0 Kudos

Hello bill.froelich

We dropped the approach to use search for call to the backend. However, I am still curious is there a better way to read the value typed into the search input field and respectively how to read it. Is there a method for this purpose, or one should locate the respective section and use the property in a way I described in my original post:

clientAPI.getPageProxy().getSections()[index].searchString;

Thank you,

Dimiter

Accepted Solutions (1)

Accepted Solutions (1)

bill_froelich
Product and Topic Expert
Product and Topic Expert
0 Kudos

Searching in MDK will trigger a redraw of the section and the search term is available in your rule to customize the search handling. There does appear to be a bug when the first section of the page is not searchable the search string is not set correctly at the section table level. I have opened an internal bug to address the problem. In the meantime, as you mention, you can work around this by simply getting a reference to the searchable section and referencing the search string from there. you can either reference the section by index or as I am doing below by name.

context.getPageProxy().getControl('SectionedTable').getSection('SectionObjectTable0').searchString

The client API allows for setting, clearing and retrieving the search string through the searchString property at the section table level.

Set Search String

export default function SetSearchString(context) {
    let sectionTableProxy = context.getPageProxy().getControl('SectionedTable');
    sectionTableProxy.searchString = "Mice";
}

Clear Search String

export default function ClearSearchString(context) {
    let sectionTableProxy = context.getPageProxy().getControl('SectionedTable');
    sectionTableProxy.searchString = "";
}

Get Search String (use workaround if first section is not searchable)

export default function GetSearchString(context) {
    let sectionTableProxy = context.getPageProxy().getControl('SectionedTable');
    let searchTerm = sectionTableProxy.searchSting;
    return context.getPageProxy().executeAction({
        "Name": "/SalesOrder/Actions/GenericToastMessage.action",
        "Properties": {
            "Message": `Current Search String -> ${searchTerm}`
        }
    });
}

Answers (0)