Joomla 5 Notice

We are pleased to announce that as of January 29, 2024, all of our Joomla extensions are compatible with Joomla 5.

For all who are still updateing from Joomla 3 to Joomla 4: Joomla 4 Migration instructions are available here:

There is now a separate Documentation for Visforms for Joomla 4 and for Visforms for Joomla 5!

Forum

Visforms Subscription user can ask questions in our forum. Please log in with the relevant user first.
Everybody can access the forum for reading.

Please only ask 1 question per topic.

Important information for almost every question:
V1: Which Visforms version is running?
V2: Which Joomla version is running?
V3: Which PHP version is running?

Auto Increment Field

More
1 year 7 months ago #9102 by NickPovey
Auto Increment Field was created by NickPovey
Could you point me at the information or make a suggestion how I might achieve the following. For the entrants for each sailing event we run, the competitors are issued with a unique tally band number and a corresponding tally band that they take when sailing (a safety system that lets us know if they might still be on the water). I would like a field that auto increments from 1 for each entrant to an event (i.e. we can reset it easily) that I can use to create some text in the receipt email. e.g " Your tally band number is XX." I suspect I could use the Id but I'm unsure how to reset that back to zero, or how to add text to that field. I'm still loving Visforms!  I've spent the last few days moving to Joomla 4 and new site templates in the hope that things can remain stable for a few years! Thank you, Nick

More
1 year 7 months ago - 1 year 7 months ago #9103 by Administrator IV
Replied by Administrator IV on topic Auto Increment Field
Hello Nick,

you can get the solution using a field of type 'Listbox Sql'.
In the SQL statement you can individually specify the start of the counter, static text and the counting method yourself.

The documentation describes the SQL-based fields.
SQL fields with option lists:
docs.joomla-4.visforms.vi-solutions.de/e...ds-with-option-list/

There is a forum topic that answers something very similar (unfortunately in German):
vi-solutions.de/de/support/forum/19-joom...g-eindeutige-id#8113

Examples of the 'SQL-Select-Statement' parameter on the 'Basic Options' tab of the field configuration of a 'Listbox Sql' type field would be something like the following.

Ascending number (1, 2, 3, ...):
Code:
select max(id) as value, max(id) as label from #__visforms_2 as label

A text plus an ascending number (A-10035, A-10036, ...):
Code:
select concat('A-', (select max(id) + 10000 from jx_visforms_2)) as value, concat('A-', (select max(id) + 10000 from #__visforms_2)) as label

The value in the field would then be with a largest data ID (without deleting = number of data records) of 35 in the data for the form, for example: 'A-10035'
The value increments by 1 for each new record.

You can also use an explanatory text as a label: Your unique tally band number

Explanation of the table name '#__visforms_2':
'#__' = placeholder for the concrete Joomla table name prefix
'2' = Form ID

The following parameters must also be set in the field configuration, 'Basic Options' tab:
'Preselect solitary option' = 'Yes'
'Reload on change of' = at least 1 field (list box, radio or check box)
'Hide when preselected' = 'Yes' or 'No' (if 'yes' the field is not visible in the form).

This parameter is also important in the field configuration, tab 'Advanced':
'Enforce unique values' = 'Yes'.

If another user has submitted the same form in the meantime, an error message appears and the form simply has to be submitted again unchanged.
However, the current value for the 'Listbox Sql' field has already changed/incremented/adjusted automatically.

It would still be important to inform the user about it by means of a suitable text in a suitable place.
It should be clear to him that he simply needs to submit the form again.

Kind regards, Ingmar

:idea: I recommend you the new and up-to-date documentation for Joomla 4:
docs.joomla-5.visforms.vi-solutions.de/en/docs/
Most of this also applies retrospectively to Joomla 3.
Please only ask 1 question per topic :-).

:idea: Ich empfehle Dir die neue und aktuelle Dokumentation für Joomla 4:
docs.joomla-5.visforms.vi-solutions.de/docs/
Das meiste gilt rückwirkend auch für Joomla 3.
Bitte immer nur 1 Frage pro Thema stellen :-).
Last edit: 1 year 7 months ago by Administrator IV.

More
1 year 7 months ago #9104 by NickPovey
Replied by NickPovey on topic Auto Increment Field
Wow!
Ingmar, I couldn't ask for better support!. Thank you

More
1 year 7 months ago #9107 by NickPovey
Replied by NickPovey on topic Auto Increment Field
I got home late and tried the above, all makes sense so thank you for that. But - I'm getting "Sorry, the request could not be performed due to a invalid Session Token" on the form field SQL test and nothing appears in the form saved results. Possibly caching or Joomla security plugin not enabled? I'll sleep on it tonight. Thank you.

Nick

More
1 year 7 months ago #9108 by NickPovey
Replied by NickPovey on topic Auto Increment Field
I deleted the field I was working on and started afresh, All works fine now! Not sure what the root cause was....

More
1 year 7 months ago - 1 year 7 months ago #9109 by NickPovey
Replied by NickPovey on topic Auto Increment Field
Everything working nicely and I am now making discoveries about the power of the customised PDF attachments - brilliant!
Last edit: 1 year 7 months ago by NickPovey.

Moderators: Administrator AVAdministrator IV
Powered by Kunena Forum