HTML5 Data Bindings Formatter Support Product Page

Answered

Updating an existing database field by adding '1'

Asked 13 Jan 2015 11:50:41
1
has this question
13 Jan 2015 11:50:41 Keith Mears posted:
I have a database record field with a numeric value and I want to update it by the value of +1 or -1 when updating the record, is it possible to update a field by adding or subtracting from an existing field value?

Replies

Replied 13 Jan 2015 12:15:14
13 Jan 2015 12:15:14 Teodor Kuduschiev replied:
Hello Keith,
you can use a hidden field on the update page, that stores the value from your database. On update record action you can format the value you insert into the database using the html5 data bindings formatter and add +1 to the hidden field value.
Replied 16 Jan 2015 16:27:28
16 Jan 2015 16:27:28 Keith Mears replied:
Hi Teodor

This works fine with a negative value and the '-1' is subtracted as expected but with a positive ('+1') it adds the digit '1' to the column, for example 18 becomes 181. Very odd, the value in the executor assignment box is written as {{($FORM.EventsTotal +1)}}. Would appreciate any further help you may have
Replied 16 Jan 2015 16:33:42
16 Jan 2015 16:33:42 Teodor Kuduschiev replied:
Hi Keith,
You first need to add a ToNumber filter, and then to add +1
Replied 16 Jan 2015 17:07:40
16 Jan 2015 17:07:40 Keith Mears replied:
Hi Teodor - sure I am doing something wrong but that has not made any difference, the value in the executor assignment box is written as the value in the executor assignment box is written as {{($FORM.EventsTotal +1).toNumber( )}}. I still get a 1 added to the end for example 15 becomes 151 and not 16 as expected.

This works fine to subtract a number {{($FORM.RemainingEntries -1)}}.

Regards

Keith
Replied 16 Jan 2015 17:39:49
16 Jan 2015 17:39:49 Teodor Kuduschiev replied:
the tonumber filter should be applied before the +1 calculation
{{($FORM.textfield).toNumber( ) +1}}
{{($FORM.textfield).toNumber( ) -1}}
Replied 17 Jan 2015 09:18:32
17 Jan 2015 09:18:32 Keith Mears replied:
Thanks that works, but the data bindings formatter does not format it that way! When this format is used the extension actually reports an "Invalid Arguments" error! Is there advanced tutorials for this extension to help as I don't know about others but I would not have considered changing what the extension added, I expected the format field in the formatter to set the calculation right.

Thanks again.

Keith

Reply to this topic