Forum Post: RE: Storing values in dataset

  • Thread starter Thread starter egarcia
  • Start date Start date
Status
Not open for further replies.
E

egarcia

Guest
Hello Meyrick, The jsdo object is a reference that points to Session object which also points to the JSDOs that it contains. Calling JSON.stringify() for the jsdo reference would give you the exception "Converting circular structure to JSON". In this scenario, you actual want to get to just the data of the JSDO (jsdo.getData()). You can call getData() to get to the data and then call addRecords() to populate the JSDO. In release 3.1 of Mobile, we have added new APIs to the JSDO to save the data to local storage and then retrieve it. The APIs are the following: - saveLocal() - readLocal() - addLocalRecords() - deleteLocal() The methods use a default "local storage area" name but you can specify a parameter if you prefer to use a different name. By default all the data in the JSDO (data and changes) are stored. There is a parameter that you can specify to only save the changes. There are also support methods hasData() and hasChanges(). Here is how your could would look with the new APIs: function jsdoTest() { var jsdo = WebService_beBasicSearch_JSDO.jsdo; // Put the object into storage try { jsdo.saveLocal(); } catch(e) { console.log("Exception while executing saveLocal();"); } // Retrieve the object from storage try { var hasLocalData = jsdo.readLocal(); } catch(e) { console.log("Exception while executing readLocal();"); } console.log('retrievedObject: ', JSON.stringify(jsdo.getData())); } I hope this helps.

Continue reading...
 
Status
Not open for further replies.
Back
Top