Get Form Element Value Activity doesn't seem to work for Date-type elements
Hello Everyone,
I am using a For Each activity to loop through an object containing the IDs of my form elements, use that value in the Get Form Element Value activity, and then check the returned value by displaying it in an Alert activity. According to the documentation, this should return the .value.value of any date element, since the first .value returns the DateTimeRef object. I'm wondering if I'm doing something wrong, as the Alert activity is always blank. I know my workflow is working otherwise because my form is full of number and text box elements whose values display in the Alert activity w/o issue.
Any insight is appreciated!
- Jack C.
-
That is because the value of a datepicker is a numeric value and not a string. Notice that the same issue occurs for the various number form elements.
The Alert activity takes only string values as parameter, while other types are invalid. Because the type of Get Form Element Value is defined as any, the workflow designer will not warn you, but typing =1234 will show The type 'number' is not valid for this input.
To convert the value to string, use =$formElementValue1.value.toString() which will show e.g. 1727733600000. This is the number of milliseconds since Jan 1st 1970. If you want to show a human readable date, use =(new Date($formElementValue1.value)).toLocaleString().
BTW the Log activity takes values of any kind, so =$formElementValue1.value will work there regardless of the type.
1 -
Hey Berend,
Thanks for that info and that totally makes sense. So, VertiGIS Studio Workflow expression windows will accept all or only some JavaScript built-in objects, like Date()? Just want to be aware for future usage.
I'm new to this suite of software and just realized I could use the Log activity yesterday, and will definitely take advantage of it!
0 -
Expressions accept some of JavaScript's built-in objects, e.g. Date is supported, but Esri objects can only be created using an appropriate activity. I'm not aware of a list of what's supported and what's not.
Note that server-side workflows and workflows running in Go may behave differently than workflows running in Web, and may not support the same set of JavaScript features.
1 -
Jack Charde One way you could possibly trick it into converting a number to a string for the Alert activity would be to do something like this:
="" + $formElementValue1.value
Or
=$formElementValue1.value.toString()
You'd need to make sure the value isn't undefined first of all, though. The first example would return “undefined” and the second would give an error.
1
Please sign in to leave a comment.
Comments
4 comments