IBM Worklight 6.0 - JSONStore error in preview after migrating from Worklight 5.0.6

264 views Asked by At

I have an app that makes use of the JSONStore in v5.0.6.
I migrated the project over to v6.0 and tried to use the Mobile Browser Simulator to test the JSONStore functionality.

I added WL.Client.getEnvironment() === 'preview' to the if condition in my collection JavaScript file.

However, when I try to get an instance of the collection, I get an error:

TypeError: WL.profileCollection is undefined

I think this maybe because the following API does not exist in version 6?

WL.namespace('WL.profileCollection');

What is the workaround for this problem?

1

There are 1 answers

0
cnandreu On BEST ANSWER

Try:

var WL = WL || {};
WL.profileCollection = WL.profileCollection || {};
//rest of your code

Remove: WL.namespace('WL.profileCollection');

A defect was opened to add WL.namespace back to the code, the work around is above.

Make sure you remove any if statements preventing the code from getting executed:

if (WL.Client.getEnvironment() === 'android' && ...) { ... }

or make sure you add the preview/common environment to those if statements. Before Worklight 6.0 JSONStore was only supported on Android and iOS environments, that's why the Wizard generated those if statements by default. With Worklight 6.0 there's a compatible JavaScript-only API available for developing JSONStore applications faster. More on the What's new section inside IBM Information Center.