Showing results for 
Search instead for 
Did you mean: 

Working with Object Tables in SAP Mobile Development Kit

0 Kudos

Hi All!
I am having trouble understanding, and gaining access to the values within object tables. My current project uses a 'checklist' which uses the object table as its main component, and each 'item' in the checklist has a boolean field in its ODATA called 'isMandatory'.
Ultimately, I need to be able to submit this checklist using a submit button at the bottom of the page, ONLY IF all items that are Mandatory have been populated. I just have no idea how to access those values...

I have attached a text file with the page structure taken. Currently, the 'isMandatory' value is being held in the statusText field.

Any help would be greatly appreciated!

View Entire Topic
Product and Topic Expert
Product and Topic Expert

Here is an example of calling read with a filter and looping over the results.

export default function ValidateItems(context) {
    let pageProxy = context.getPageProxy();
    let clientData = pageProxy.getClientData();
    var valid = true;
    return'/MDKApp/Services/Sample.service', 'MyEntitySet', [], `$filter=isMandatory eq 'X'`).then((results) => {
        if (results) {
            for (let i = 0; i < results.length; i++) {
                let item = results.getItem(i);
                // Validate item properties are set, can do as a single check or by muiltiple checks on the item
                if (item.prop1 && item.prop2) {
                    valid = true;
                } else {
                    valid = false;
                    // Display an error message? and quit loop?
            return valid;

The example is for the validation check is just a simple check.  You can expand that based on your requirements and decide what you want to do when a validation failure occurs. 

0 Kudos
Thank you! I've recently got the debugger working, and I can see exactly how this works 🙂 Thanks Bill!