Page 1 of 1

How to Specify a Local Storage Variable as the Where Value?

Posted: Tue Sep 30, 2014 1:45 am
by BSalita

How can a local storage variable be specified as the Where value in a query service request?

I navigated in the IDE to my Query Service-Request-Where-Value and set Where's Value to

Code: Select all

 localStorage.getItem('SelectedPosition') 

Where SelectedPosition is a local storage variable confirmed to contain: {"Name": "GOOG"} Hard coding the string in Value and clicking Test works fine. Shouldn't the above expression work or is there some additional magic required?


How to Specify a Local Storage Variable as the Where Value?

Posted: Tue Sep 30, 2014 3:17 am
by Yurii Orishchuk

Hi BSalita,

Please follow this solution:

1 Open your service mapping.
2 Find "where" request parameter.
3 Click "JS" on this "where" parameter.
5 Populate JS editor with following code:

pre

//Note: you should replace "SelectedPosition" with your lsv name.
var selected = localStorage.getItem("SelectedPosition");

var whereObject = {"Name": selected};

return JSON.stringify(whereObject);

/pre

That's all.

Regards.


How to Specify a Local Storage Variable as the Where Value?

Posted: Tue Sep 30, 2014 6:30 am
by BSalita

I don't see "JS" on the "where" parameter. Is it really on the new UI screens? I think the issue is that I've never seen "JS" in the new UI but IIRC I saw it in the old UI. Perhaps I'm not understanding what is meant by "service mapping".


How to Specify a Local Storage Variable as the Where Value?

Posted: Tue Sep 30, 2014 7:12 am
by Kateryna Grynko

Hello,

Actually, request mapping is 'Before send' and response mapping in 'Success' now. Please find them in your service.


How to Specify a Local Storage Variable as the Where Value?

Posted: Wed Oct 01, 2014 10:58 pm
by BSalita

This question has revealed a number of UI issues:

  1. If you delete the default "Before send-Mapping" and "Success-Mapping", the data source page has no way of showing the "Add" button again. Even if you create events, it still won't show "Before send" and "Success" Add buttons, only the events are shown.

  2. There's no title to this page and some other UI pages. The URL doesn't contain a page identifier. Thus, it is difficult to explain to a user, and visa-versa, which page you are on and where you should be. Every UI page needs a unique, descriptive title.


How to Specify a Local Storage Variable as the Where Value?

Posted: Thu Oct 02, 2014 4:35 am
by Yurii Orishchuk

Hi BSalita,

  1. Here is how to add event if you delete it: http://prntscr.com/4s9zy9/direct

  2. Every page has ID in URL.
    See details: http://prntscr.com/4sa0x8/direct

    Regards.