Armand
Posts: 0
Joined: Sat Jan 03, 2015 9:04 am

Cannot get query_service to populate detail page with local storage mapping

I have a collection (doctortypes). I populate a list with it. My hidden label is a field TypeID. On click I grab this TypeID and store it in local storage.

On my doctors detail page I invoke query_service to return all doctors for selected type.

On the Before Send event I mapped local storage to query with "where" and my JS is

var test = {"TypeID": "'+ _doctortypid + '"};
return test;

It return blank page. I know that the correct id is returned on click.
My Success event is correctly mapped and works 100% when I delete the Before Send event mapping, but then obviously return the whole dataset.

This is my first appery app. I have really looked at all tutorials I could find.

Thx

Armand

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

Cannot get query_service to populate detail page with local storage mapping

Hi Armand -

Please check if you are passing the valid data types and value to the query service.
What result you are getting when testing your service?

Armand
Posts: 0
Joined: Sat Jan 03, 2015 9:04 am

Cannot get query_service to populate detail page with local storage mapping

Datatype is number. If I put a label on detail page and read storage into it I get correct value of storage back.

If I test query-service with the following script it work 100%

{"TypeID":1}

My local storage is type number.

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

Cannot get query_service to populate detail page with local storage mapping

Can you show how exactly you define the storage variable and reading it's value?

Armand
Posts: 0
Joined: Sat Jan 03, 2015 9:04 am

Cannot get query_service to populate detail page with local storage mapping

In Model and Storage I have declared a variable name: _doctortypid Local storage Type = number.

In master page I have list box with label(doctortypeid) mapped to collection DoctorTypes field TypeID.

On listitem click event action Set Storage Variable. Variable name from drop down is _doctortypid bind to component is checked. Target component is label(doctortypeid)
Property name = Text.

On detail screen on Load event I Invoke Service(restservice1). Restservice is a query_service.

I then mapped the local storage on the Before Send event.
On the Succes event I mapped the body to the page.

I populate the detail page with the storage value and it works 100%, So I am sure that the detail page is getting the correct value.

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Cannot get query_service to populate detail page with local storage mapping

Hi Armand,

You return an object. But "where" parameter should have "string" type.

So you need to convert your object to "string".

Here is a code:

pre

var currentValue = Apperyio.storage._doctortypid.get();

//Take a look into browser console - to see actual value.
console.log("currentValue = " + currentValue);

var whereObject = {"TypeID": currentValue};

return JSON.stringify(whereObject);

/pre

Regards.

Armand
Posts: 0
Joined: Sat Jan 03, 2015 9:04 am

Cannot get query_service to populate detail page with local storage mapping

Yurii

Thanks, I am almost there. If I read the whereObject into my console the answer is:
whereObject ={"TypeID":"1"}

where the correct answer should be

whereObject ={"TypeID":1}

The number is incorrectly returned as string and not value?

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Cannot get query_service to populate detail page with local storage mapping

Hi Armand,

You can parse value to integer with following code to achieve it:

pre

var currentValue = Apperyio.storage._doctortypid.get();

//Parse to int
var currentValue = parseInt(currentValue);

//Take a look into browser console - to see actual value.
console.log("currentValue = " + currentValue);
var whereObject = {"TypeID": currentValue};
return JSON.stringify(whereObject);

/pre

Regards.

Armand
Posts: 0
Joined: Sat Jan 03, 2015 9:04 am

Cannot get query_service to populate detail page with local storage mapping

Thank you very much. It is working now.

Return to “Issues”