RichardGolko
Posts: 0
Joined: Thu Oct 25, 2012 11:25 pm

So hard...

The query works with single or double quotes as you can see from the response i the above image. Now how do I remove that from the test window... add the service to my BusinessHours screen and use a local storage variable in the place of the actual StationID number in the test query above.

I've tried a bunch of ways but nothing has worked.

In the mapping screen, there is a "where" and next to it the blank Value textbox and then the Add Javascript button. I've tried the above query in the value textbox and yes it works. I assume I remove it from the Value column and move it over to the Javascript button popup but what do I put in there?

I've tried
var x = localStorage.getItem("studioID");
rethrn "where={\"StudioID\""""\"" + x + \"") "";

But that doesn't work."

RichardGolko
Posts: 0
Joined: Thu Oct 25, 2012 11:25 pm

So hard...

I want to display 'closed' when there is no value in a certain database field, otherwise I want to display the value in the field.

Here's the code I put in the Javascript popup for the screen control (a label) that I mapped a database field to.

var x = Tiggzi('OpenTimeLabel').text();

alert(x);

if (x == null || x.length==0)
{
Tiggzi('OpenTimeLabel').text("closed");
}

The alert always shows absolutely nothing for each record returned even though there is data there for all but one (the one I want to display 'closed').
A new alert pops up each record and x is nothing.

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

So hard...

var x = localStorage.getItem("studioID");
return '{"StationID":"'+x+'"}"';

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

So hard...

Where exactly do you run this code, in output mapping for a label?

RichardGolko
Posts: 0
Joined: Thu Oct 25, 2012 11:25 pm

So hard...

yes, see image below..
once we get the query to work on StationID, I have to massage the data it returns.
OpenTime is the database field mapped to a label, OpenTimeLabel. If OpenTime as a value, display it; if not it means the business is closed, dispay "closed..
Image

RichardGolko
Posts: 0
Joined: Thu Oct 25, 2012 11:25 pm

So hard...

THAT'S IT! Thank you! YES! Now I can move on... much appreciated. For anyone reading this, "studioID" above should be "stationID"

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

So hard...

Hello! The problem is that JS invokes before value maps on UI. If you want to show an alert if value is empty then you have to work with value parameter. This parameter sends inside function. For example if you map to BusHourGrid, when you add the JS in value will be $[] from where you should take necessary subvalue value.opentime, if you map on opentimelabel - then you'll get what you mapped on that element. Then you can check if this value is empty:

if(value) { alert(value);} else {alet("nothing")}

Return to “Issues”