Skip to Content

Getting odata into an array

Hi,

I have set oModel to consume the odata in my ui5 application. I want to store that odata in a seperate array. When the user enters "userid" and "password", it should check in this array for the matching "customerid". If it matched it should navigate to the next message else throw an error statement.

Please help me with some code sample if possible.

Thanks,

Srinivasan

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Posted on Jul 05, 2016 at 06:45 AM

    If oModel is a JSON Model then writing the below code will return an array of objects, you can store it in a variable which will nbe an array. The use this array to validate the entered userid and password.

    var myArr = oModel.getData();
    
    Add a comment
    10|10000 characters needed characters exceeded

    • Hi Vijay,

      Thank you for the suggestion. I have got my odata into the array with the following code

      oModel.read("/ServiceRequestCollection?$filter= CustomerID eq '1001192'",{ filters: [oFilter], success: function(oData, response) { var oResult = []; oResult = oData.results; console.log("result", oResult); // oModel.setData(oResult); oTile.setModel(oResult); }, failed: function(oData, response) { alert("Failed to get InputHelpValues from service!"); }

      });

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.