Create a COUNTER field with auto increment based on another field value

7 views
Skip to first unread message

nikonaum

unread,
Aug 20, 2019, 2:05:50 PM8/20/19
to orb...@googlegroups.com
I'm a knew user to orbeon and I'm trying to create a form with a counter
field base on the value of the previous field.
Can someone guide me to a code snippet and give me some basic advice.
Currently I'm using latest Orbeon PE addition with temporary 3 months
license which ends at the end of the month.
So the basic sketch of what I'm trying to do is:
Control field name: document-type
Control field name: counter

If "document-type" begins with "A" "counter"= previous A type document
counter value + 1

If setup a MySQL persistent connection and can create a trigger based tables
fine.

Thank you very much!


--
Sent from: http://discuss.orbeon.com/

Alessandro Vernet

unread,
Aug 20, 2019, 6:10:29 PM8/20/19
to orb...@googlegroups.com
Hi,

When you're saying that you'd like the value to be set to the "value of the
previous field" + 1, what do you mean by "previous field"? Do you have a
repeated section or repeated table, or is there just 1 such field in your
form and you'd like the number to be set automatically every time someone
fills a new form so the number is different each time?

‑Alex

-----
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet

nikonaum

unread,
Aug 23, 2019, 1:21:35 AM8/23/19
to orb...@googlegroups.com
I want the number in the field to be incremented every time someone
fills a new form.

Alessandro Vernet

unread,
Aug 23, 2019, 1:41:02 PM8/23/19
to orb...@googlegroups.com
Got it. You can do this by creating a table to keep track of that sequence
number in MySQL, and using services and actions to update and read that
sequence number from your form. We have more information on how to do this
with MySQL on the page linked below, and can also envision some "native"
support for this feature in the product so doing this would be more
straightforward.

https://github.com/orbeon/orbeon-forms/issues/4162

You'll let me know if this works for you,

‑Alex

-----
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet

Alessandro Vernet

unread,
Aug 30, 2019, 12:13:43 PM8/30/19
to orb...@googlegroups.com
Did you get a chance to try the technique described in the RFE to create an
auto-incremented field? If so, did it work for you?
Reply all
Reply to author
Forward
0 new messages