on 11-30-2021 4:05 AM
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:
Every hint will be highly appreciated because I was not able to find anything in the documentation.
Best Regards,
Dimiter
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}`
}
});
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.