Problem with an instant web form for finding the perihelion

Hi,

I’m trying to CloudDeploy a little form that takes the name of a planet and returns the perihelion. Here’s the code.

planetDistance[a_]:=Module[{D},D=PlanetData[Entity["Planet", a], "Perihelion"]]
CloudDeploy[FormFunction[{"a"->"Planet"},planetDistance[#a]&,"GIF"]]

The function itself seem to work okay in the notebook…

planetDistance["Neptune"]
2.7710865×109mi

I get this message

Screenshot2015-04-3010.34.48.png

Thank you.

vr/MB

Your function implicitly assumes the input will be a string; however, when you make a choice in your form “a” is returned as an entity and not as a string.

You need to reformulate your planetDistance function to operate on an entity rather than a string.

planetDistance[a_Entity] := PlanetData[a, "Perihelion"]
planetDistance[Entity["Planet", "Neptune"]]

Thank you, Emerson. This worked, and I think I understand why :slight_smile:

vr/MB