Sean B.
Posts: 0
Joined: Tue Jul 22, 2014 9:29 pm

Database Query Help

Hi

I am building my first app and am very new to building apps and working with databases. I need to write a query that need to search the appery.io database I created, based on a single value that the user will supply.

For the user to get the information he requires he will supply a single value (monetary) and it must then compare between 2 values that exist in each table row to find the correct row and then display the values of that row in the corresponding mapped app fields.

Not sure where to start, will I do this with the where function for the database or in JS ?

http://appery.io/app/mobile-frame?src...

(the part I am working on is the transfer registration calc)

Any help would be greatly appreciated as I am stuck...

Kind Regards
Sean

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Database Query Help

Hello Sean,

This tutorial should be helpful for you: http://devcenter.appery.io/tutorials/...

Sean B.
Posts: 0
Joined: Tue Jul 22, 2014 9:29 pm

Database Query Help

Thanks Evgene,

This helped allot. I managed to display results from the database in the various fields. How would I do the following :

I have a value that needs to be compared to 2 database values in a table row and if equal to or higher than first value or equal to or lower than second value in the same database table row, then it must display those values in the output.

I have manage to display the values if I select the one field matches exactly but I need the query to check these values before displaying the data for the value range it falls in.

As always your assistance would be greatly appreciated.

Kind Regards
Sean

Sean B.
Posts: 0
Joined: Tue Jul 22, 2014 9:29 pm

Database Query Help

Hi

How would I format the output values that is displayed from the query result.

Currently I have a monetary value that displays as a straight number value

eg 100000

I need to format the value to look like this :

eg R 100 000.00

I have tried a couple of JS edits to the response fields but not getting any results.

Any assistance would be greatly appreciated.

Kind Regards
Sean

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Database Query Help

Sean,

1) You can add as many conditions as you want to the where parameter:
http://devcenter.appery.io/documentat...
2) You can add js code to format the data in the mapping:
http://devcenter.appery.io/documentat...

Sean B.
Posts: 0
Joined: Tue Jul 22, 2014 9:29 pm

Database Query Help

Hi Evgene

Managed to get the results working with loads of reading and lots of coffee.

I'm still stuck on getting the output of a query formatted in any form. I have managed to format responses before in the first part of my app but I am not sure where to use the formatting JS, should it be in the data/response/component/JS or should I invoke the javascript from the same button that runs the database query.

Please help, this is obviously trivial but your assistance would be greatly appreciated.

Kind Regards
Sean

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Database Query Help

Hi Sean,

Please click 'Add JS' on mapping page:
http://devcenter.appery.io/documentat...

Sean B.
Posts: 0
Joined: Tue Jul 22, 2014 9:29 pm

Database Query Help

Hi Katya

I managed to come right with most of my calculations but I am stuck on trying to do the following.

I have mapped various values that I get from the database to some localStorage variables. I have managed to style most of them as needed but I need to do a simple calc on these values to create a value for a total field. I have tried for many hours without success.

Is it possible to use the localStorage variables to calculate another value and where would I apply the js to do this. I have attached an image to possibly illustrate what I have done and the last thing I need to do. Image

I know this is most likely outside of the scope of your support but I would really appreciate it if you could help me.

This is the code I prepped but not sure if it is 100% and not sure where to insert this :

var amount_attorney = localStorage.getItem("amount_attorney");
var amount_deeds = localStorage.getItem("amount_deeds");
var amount_transfer = localStorage.getItem("amount_transfer");
var amount_misc = localStorage.getItem("amount_misc");
var transferTotal = Number(Apperyio("transferTotal").val());

var transferTotal = Attorney_Fees + Deeds_Fees + Transfer_Duty + misc_costs ;

Apperyio('transferTotal').text('R' + transferTotal.toFixed(2));

Kind Regards
Sean

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

Database Query Help

Hi Sean,

Here is best way to implement what you want:

1 Add "amount" LSV http://i.imgur.com/mSfURgg.png

2 Make link from $[] to this lsv http://i.imgur.com/nNIEUPR.png

3 Click "Add JS/Edit JS" and populate it with following code: http://i.imgur.com/IisJGes.png

pre

if(value.constructor == Array)
return;

// Start attorney block //
//Here you can access direct "value" object as returned from response object.
var amount_attorney = value.amnt_attorney;
var attorneyFees = value.amnt_deeds;

var attorneyFees = amount_attorney * 1.14 ;

Apperyio('attorneyFees').text('R ' + attorneyFees.toFixed(2));
// End attorney block //

//Here you need to add other calculation block lik attorney block.

/pre

4 Add other calculation blocks in the JS code.

5 Delete - all LSVs that's you have created before for this goal.

That's all.

Regards.

Sean B.
Posts: 0
Joined: Tue Jul 22, 2014 9:29 pm

Database Query Help

Awesome, Thanks Yurrii

My app is now functionally complete, just need to tidy it a bit up and make it look pretty.... Thank you so MUCH :-)

Regards
Sean

Return to “Issues”