Page 2 of 2

So hard...

Posted: Tue Nov 13, 2012 2:06 am
by RichardGolko

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."


So hard...

Posted: Tue Nov 13, 2012 2:12 am
by RichardGolko

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.


So hard...

Posted: Tue Nov 13, 2012 3:47 am
by maxkatz

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


So hard...

Posted: Tue Nov 13, 2012 3:48 am
by maxkatz

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


So hard...

Posted: Tue Nov 13, 2012 4:28 am
by RichardGolko

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


So hard...

Posted: Tue Nov 13, 2012 4:38 am
by RichardGolko

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


So hard...

Posted: Tue Nov 13, 2012 11:09 am
by Maryna Brodina

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")}