2
$\begingroup$

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?

$\endgroup$
1
$\begingroup$

Afaict Dataset does not have associated any fancy export options. It is either an InputForm (1D input or what it evaluates too) or a StandardForm (grid interface).

Mathematica Notebooks by default generate StandardForm output so that it why it works there.

PNG, or any other raster/vector image formats are generated from the StandardForm so this is why you see expected images for those ExportForms.

For WolframCloud's FrontEnd StandardForm is only supported in cloud notebooks or in "CloudCDF" ExportForm. (not sure how exactly cdf and nb differ in cloud).

The default ExportForm in FormFunction is CloudCDFElement which converts evertyhing to html, except Manipulate/DynamicModule (guess based on observation). And Dataset exported to HTML is just a plain input form string as explained above.

TL;DR;: Use "CloudCDF" for FormFunction export form or any other image format.

$\endgroup$
  • 1
    $\begingroup$ Perfect. By using ExportForm[Dataset[Databin[#"Databin ID:"]], "CloudCDF"] & as the output, it displayed the way I was looking for. I had originally avoided the option because I thought it required the plugin (which it doesn't). $\endgroup$ – kickert Jun 15 '18 at 15:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.