Message Boards Message Boards

Displaying Databin as a Dataset table in a FormFunction Cloud Deployment

GROUPS:

I am trying to set up a cloud deployed FormFunction where a user can enter a public databin ID and then view the contents formatted as a dataset. I keep running into issues where the output of the form returns straight text rather than the table I am looking for.

CloudDeploy[
 FormFunction[{"Databin ID:" -> <|
     "Help" -> "Enter the ID of a public Databin", 
     "Interpreter" -> "String"|>, }, 
  Dataset[Databin[#"Databin ID:"]] &], Permissions -> "Public"]

And here is a snippet of what I am getting in return when I try to view the databin as a dataset:

Dataset[{<|"Name" -> "Ben", "Email" -> "fake@gmail.com","Timestamp" -> DateObject[{2018, 5, 18, 12, 26, 55.98299980163574}, "Instant", "Gregorian", -7.]|><|"Name" -> "bob", "Email" -> "anotherfake@gmail.com","Timestamp" ->  DateObject[{2018, 5, 18, 12, 30, 33.210999965667725}, "Instant", "Gregorian", -7.]|>.....

I can replace

Dataset[Databin[#"Databin ID:"]]&` 

with this

ExportForm[Dataset[Databin[#"Databin ID:"]], "PNG"] &

and it will display an image of what I am looking for, but any other formatting option ("HTML", "WL", etc.) either fails or returns the same string of text as before

Any idea what I am missing?

POSTED BY: Ben Kickert
Answer
6 days ago

The more I look into this, the more I think it may be a bug instead of a coding issue. The reason being is that if I include the exact same code as above without using CloudDeploy in Mathematica, the result displays as expected with a Dataset table showing the databin contents. Furthermore, if I use the following code to simply CloudDeploy a Databin formatted as a Dataset, it also shows correctly.

CloudDeploy[Dataset[Databin["uI5TknW0"]]]

I just don't understand what would cause such a discrepancy with a CloudDeploy.

POSTED BY: Ben Kickert
Answer
6 days ago

After much trial and error, and eventually guidance from a kind soul on StackExchange, I was finally able to troubleshoot the problem. The fix was to use ExportForm to deploy it as a CloudCDF. I initially avoided this option because I thought it would require a CDF player installation for users. Here is the final working code:

CloudDeploy[
 FormFunction[{"Databin ID:" -> <|
     "Help" -> "Enter the ID of a public Databin", 
     "Interpreter" -> "String"|>, }, 
  ExportForm[Dataset[Databin[#"Databin ID:"]],"CloudCDF"] &], Permissions -> "Public"]

Still not sure why that option has to be set, but it is great to now know the fix.

POSTED BY: Ben Kickert
Answer
6 days ago

Group Abstract Group Abstract