Bhupinder Chawla
Posts: 0
Joined: Thu Aug 28, 2014 1:21 am

Concatenating Database Output into a List Item

Thanks Yuri! It worked like a charm!

Bhupinder Chawla
Posts: 0
Joined: Thu Aug 28, 2014 1:21 am

Concatenating Database Output into a List Item

Hi Yurli,

Another quick question. I have a column in a collection labeled Photo with the type as File. I am able to add a file as the media manager opens and allows me to select a file.

My first challenge is to display this as an image at run-time corresponding to the selected item.

I have in a page the image and I know the selected item. I use the query service and map it to this image in response using the right where clause for the selected item. But no picture appears in the image.

I have tried to read about it but not able to understand. Can you please provide me the steps to make this happen? Thanks!

The second challenge is to let users select the item image and save it into the database. The challenge I have is the same as above - using create (or update if there is a change) service, I am not able to do so. Currently, I go into the database, click on the Photo field of the selected row (new or existing) and the media manager opens up for me to select as mentioned at the start. an you please provide me the steps to make this happen? Thanks!

Best Regards
Bhupinder Chawla

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

Concatenating Database Output into a List Item

Hi Bhupinder,

1 "File" column returns following JS in service response:

pre

Code: Select all

     "fileCol":{ 
         "fileName":"23d278e5-1b40-4768-90a1-818f47ce2f1e.answer.txt", 
         "originalFileName":"answer.txt" 
     } 

/pre

In accordance to Files API( http://devcenter.appery.io/documentat... ) you can build on "fileName" base - direct URL to this file.

So here is code template for file direct URL:

pre

https://api.appery.io/rest/1/db/files/[databaseID]/[fileName]?sessionToken=[userSessionToken]&masterKey=[masterKey]

/pre

2 To update or create service you need to specify in service request parameters following:

http://prntscr.com/4pdtei/direct

Regards.

Bhupinder Chawla
Posts: 0
Joined: Thu Aug 28, 2014 1:21 am

Concatenating Database Output into a List Item

Yurii,

Here is the screen shot of the database which has a column named TestPicture. When I click in this cell, Media Manager window pops up to select a file.

Image

I have use the following mapping:

Image

And have added the following JavaScript code:

//Note: please replace "[databaseID]" with your DB id.
var urlToSave = "https://api.appery.io/rest/1/db/files..." + value;
return urlToSave;

However, I cannot get any value.

I am not able to see the picture you have shown.

My dataset is:

[
{
"id":"54036a2ae4b055c018db1e52",
"LocationName":"TPC Sugarloaf",
"createdAt":"2014-08-31 18:32:10.319",
"_updatedAt":"2014-09-23 01:23:51.072",
"AddressLine1":"2595 Sugarloaf Club Drive",
"City":"Duluth",
"State":"GA",
"ZipCode":30097.0,
"Phone":"(770) 418-1113",
"Website":"http://www.tpcsugarloaf.com",
"TestPicture":{
"fileName":"4c5a6683-a7c2-477a-989e-dff3a8c5d7d6.LuckyChawla.jpg",
"originalFileName":"LuckyChawla.jpg"
}
}
]

and the URL works: https://api.appery.io/rest/1/db/files...

However, I am not able to form it with JavaScript as I cannot get the fileName properly. Please guide me.

Thanks!

Best Regards
Bhupinder Chawla

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

Concatenating Database Output into a List Item

Bhupinder,

I just show you in new app builder version.

But you still on 14 release one.

So for you solution is following:

1 Open mapping.

2 Find link to image component "asset" property. http://prntscr.com/4pgtpv/direct

3 Click "Add js" and populate JS editor with following code: http://prntscr.com/4pgtm4/direct

pre

//Note: you should replace "52fd3d06e4b0a25c11c89917" with your DB id.
var urlToSave = "https://api.appery.io/rest/1/db/files/52fd3d06e4b0a25c11c89917/" + value.fileName;
console.log(urlToSave);
return urlToSave;

/pre

Regards.

Bhupinder Chawla
Posts: 0
Joined: Thu Aug 28, 2014 1:21 am

Concatenating Database Output into a List Item

Yurii,

Thank you very much for this. It works.

Whenver, I have tried to upgrade to the new release, it gives an error. And the app does not open. So I have to restore to the earlier version.

I have a silly question. How do you get Database ID in a live app? I do not want to hardcode the above.

Thanks!

Best Regards
Bhupinder Chawla

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

Concatenating Database Output into a List Item

Hi Bhupinder,

There is some problems upgrade some old projects.
Currently our developer team work on it.

So we update you here when it will be fixed.

Regards.

Bhupinder Chawla
Posts: 0
Joined: Thu Aug 28, 2014 1:21 am

Concatenating Database Output into a List Item

Yurii,

How do I populate the Select control with data from the database?

Thanks!

Best Regards
Bhupinder Chawla

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

Concatenating Database Output into a List Item

Hi,

You can do it in the same way as populate list :)

Here is brief plan for it:

1 Add "list/query" service on the page.
2 Invoke this service on "page show" event.
3 Open page in "data" mode. Edit mapping for this service as following:
http://prntscr.com/4prp63/direct

Regards.

Bhupinder Chawla
Posts: 0
Joined: Thu Aug 28, 2014 1:21 am

Concatenating Database Output into a List Item

Yurii,

Another thing!

I have a collection of employees who have a manager. I tried to use the collapsible control with a list item. It does not work. It gives me: first, multiple rows of same manager; and second, in the list, it repeats the employee (multiple rows again!).

Can we not use the collapsible control to show a master detail kind of information? It will be awesome, if we can.

If it is possible, what is the best way?

Best Regards
Bhupinder Chawla

Return to “Issues”