Casting a N/A value into an orbeon Date field and an Orbeon number field

25 views
Skip to first unread message

Dylan Strachan

unread,
Dec 10, 2020, 5:40:04 PM12/10/20
to Orbeon Forms
Hello All,

I am trying to cast N/A to date and number fields if they are null and if a question is selected as no. What I have right now is:

if($Control1 = 'No') then ($Control2 [string() castable as xs:string] = 'N/A') else .

With Control2 being a date field, and Control1 being a Yes/No radio button field. I also need this logic for Control2 if it were a number field. 

Normally we would set up logic to send N/A through the hide stream and we have done that before. In this case however we need the N/A to be able to be seen within the form as the agency using this form needs to be able to see N/A in the field upon printing.

Any help would be greatly appreciated!

Best,
Dylan

Alessandro Vernet

unread,
Dec 11, 2020, 2:16:35 AM12/11/20
to orb...@googlegroups.com
Hi Dylan,

Would you be able to create a simple form where you have those fields setup,
maybe with Form Builder on https://demo.orbeon.com, so we can see and run
what you have? Then you can share with us here the link to the form, and
also attach the source to your message (data on https://demo.orbeon.com
being publicly accessible, it can disappear at any time).

(I am a bit puzzled by Control2 being a date field, but sometime having a
value of "N/A". Obviously, that isn't a valid date, and would be unexpected
for a date field.)

-Alex

-----
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
--
Sent from: http://discuss.orbeon.com/

Dylan Strachan

unread,
Dec 11, 2020, 5:53:56 PM12/11/20
to orb...@googlegroups.com
Hello Allesandro,

I have created a Test form called Demo_NA_Functionality.

I need N/A to default to all fields if they are not answered. In some cases they will not be visible because of the logic put into the sections with dependencies on the answer to the Third party payer question.  Basically if upon form submission these fields are null I need them to display N/A.  this goes for every field after the Sample Insurance? field.

Thank you for your help and let me know if you need anything else.

Best,
Dylan

--
You received this message because you are subscribed to a topic in the Google Groups "Orbeon Forms" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/orbeon/qPVq1WxTg-g/unsubscribe.
To unsubscribe from this group and all its topics, send an email to orbeon+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/1607670991932-0.post%40n4.nabble.com.

Alessandro Vernet

unread,
Dec 13, 2020, 10:25:22 PM12/13/20
to orb...@googlegroups.com
Hi Dylan,

Got it, so you need the value of any field left empty to become "N/A" in the
data you submit. By "submit", are you referring to the `send()` in a
process? If so, you could maybe add to your process after you save the data,
but before the `send()`, something like:

xf:setvalue(
ref = "//*[empty(*) and xxf:is-blank(.)]",
value = "'N/A'",
all = "true"
)

For more on the `xf:setvalue()` action, see the link below. Would something
like this works for you?

https://doc.orbeon.com/form-runner/advanced/buttons-and-processes/actions-xforms#xf-setvalue

Alessandro Vernet

unread,
Dec 21, 2020, 9:07:42 PM12/21/20
to orb...@googlegroups.com
Hi Dylan, did you get a chance to look into using `xf:setvalue()` in your
process, to have value of any field left empty to become "N/A"? If so,
you'll let me know if it worked.
Reply all
Reply to author
Forward
0 new messages