Changes for page Datenbankzähler-Plugin
Change comment:
There is no comment for this version
Summary
-
Page properties (3 modified, 0 added, 0 removed)
Details
- Page properties
-
- Author
-
... ... @@ -1,1 +1,1 @@ 1 -XWiki. awa1 +XWiki.gru - Default language
-
... ... @@ -1,0 +1,1 @@ 1 +de - Content
-
... ... @@ -1,31 +1,106 @@ 1 +[[**Plugin download**>>url:https://customer.formcycle.eu/index.php/apps/files/?dir=/FORMCYCLE%20-%20Plugins%20Customer/fc-plugin-bundle-dbcounter&fileid=5521||target="_blank"]] (requires login) 2 + 1 1 {{content/}} 2 2 3 -{{figure image="dbcounter_ plugin_installation_en.png"}}4 -The database counter plugin may be installed as either a client plugin or a system plugin. It requ ries no additional configuration.5 +{{figure image="plugin_dbcounter_workflow_select_en.png" width="600"}} 6 +The database counter plugin may be installed as either a client plugin or a system plugin. It requires no additional configuration. Once installed, it offers to new workflow actions: //Variable// and //Counter.//. The //Counter// action requires you to choose a fixed counter that you would like to change. In contrast, the //Variable// action lets you choose the counter based on the submitted form data. 5 5 {{/figure}} 6 6 7 -The database counter plugin lets you create one or more globalcounter in a database.The countervaluemaybeincremented,decremented orresetduring[[workflow processing>>doc:Formcycle.UserInterface.MyForms.WorkflowProcessing.WebHome]].Somepossible usescases are:9 +The database counter plugin lets you create one or more counter in a database. It also adds a new menu entry to the backend where you can view and edit all available counters. You can then use the [[workflow processing>>doc:Formcycle.UserInterface.MyForms.WorkflowProcessing.WebHome]] to increment or decrement the counter. This plugin is subject to additional charge. 8 8 9 -* A reservation form that counts the number of participants. When a certain limit is reached, further form submissions are blocked. 10 -* Generating a custom ID for a form record that is independent of the internal FORMCYCLE process ID. This is useful especially when the ID needs to conform to a certain pattern or has to be reset in regular intervals. 11 -* Repeating the actions of a certain state //n// times, where //n// is set depending of a submitted form value. 11 +Some of the possible use cases include: 12 12 13 -Furthermore, it is also possible to access the current value of the counter via a [[system variable>>doc:Formcycle.UserInterface.Variables]] during workflow processing; or via [[an AJAX request >>doc:Formcycle.FormDesigner.CodingPanel.ScriptTab.WebHome]] from within a form. 13 +* A registration form for a weekly event, when you need to keep track of the number of registered participants. You can then block new registrations for a certain date when the maximum number of participants has been reached. 14 +* Generating a unique {{smallcaps}}id{{/smallcaps}} for a form record that is independent of internal {{smallcaps}}id{{/smallcaps}}s used by {{formcycle/}}. Useful especially when the {{smallcaps}}id{{/smallcaps}} needs to conform to a certain pattern or needs to be reset in fixed intervals. 15 +* Running the [[actions>>doc:Formcycle.UserInterface.MyForms.WorkflowProcessing.Actions.WebHome]] of a certain [[state>>doc:Formcycle.UserInterface.MyForms.WorkflowProcessing.States.WebHome]] n-times, where //n// is determined by the value of a submitted form field. 14 14 15 - Eachcounterhasgotbotha nameas wellasa unqiue[[UUID>>https://en.wikipedia.org/wiki/Universally_Unique_Identifier]]. TheUUIDuniquelyidentifiesa counterandisused whenquerying the counter valuewith an AJAX request.17 +Once the plugin is installed, you can manage the available counter in a separate backend page. You can check which counters exist currently and add or delete counter. The current value of each counter is displayed as well, and if necessary, you can also change the counter's value. 16 16 17 - ==Workflow action"Counter"==19 +In addition, this plugin offers two new [[workflow>>doc:Formcycle.UserInterface.MyForms.WorkflowProcessing.WebHome]] [[actions>>doc:Formcycle.UserInterface.MyForms.WorkflowProcessing.Actions.WebHome]]: //Counter// and //Variable//. The action //Counter// requires you to select a predefined counter. The action //Variable//, on the other hand, lets you select a counter based on the value of a submitted fo m field. See the sections on each action below for further details. 18 18 19 -Once the plugin is installed, you can choose a new action in the [[workflow processing configuration>>doc:Formcycle.UserInterface.MyForms.WorkflowProcessing.WebHome]]. The action is a plugin action named //Counter//. You can use this action to modify the value of a counter or reset it in regular intervals. 20 -=== Allgemeine Einstellungen === 21 +Lastly, you can also access the current value of a counter either via a [[variable>>doc:Formcycle.UserInterface.Variables]] during workflow processing or [[via an {{smallcaps}}Ajax{{/smallcaps}} request from within an opened form>>doc:Formcycle.FormDesigner.CodingPanel.ScriptTab.WebHome]]. 21 21 22 -{{figure image="dbcounter_plugin_action_base_settings_en.png"}} 23 -Base settings for the workflow action //Counter//. Here you can choose which counter should be changed and in what manner. 23 +Each counter has got both a name as well as a unique [[{{smallcaps}}Uuid{{/smallcaps}}>>https://de.wikipedia.org/wiki/Universally_Unique_Identifier]]. The {{smallcaps}}Uuid{{/smallcaps}} uniquely identifies a counter and is used, for example, when querying the counter's current value via an {{smallcaps}}Ajax{{/smallcaps}} request. 24 + 25 +This is plugin bundle that includes two workflow action plugins, one placeholder replacer plugin, and one servlet action plugin. The following sections describe these plugins in more detail. 26 + 27 +== Menu entry "Counter configuration" == 28 + 29 +{{info}} 30 + This plugin adds a new [[role permission>>doc:Formcycle.UserInterface.UserSettings.Roles]] that controls whether a user is granted access to this menu entry. Contact your administrator in case you do not see the menu entry and believe you should have access. 31 +{{/info}} 32 + 33 +{{figure image="plugin_dbcounter_config_base_en.png" width="600"}} 34 + The menu with an overview of all existing counter. You can add or delete counter, or modify existing counters.{{/figure}} 35 + 36 +Once installed, a new menu entry appears in the main menu bar to the left. Please note that you may have to sign out and sign in again. The menu //Counter configuration// contains an overview of all existing counters, including their name and their current value. You can modify or delete existing counter, or add new counters. 37 + 38 +Press the plus icon to the top left to add a new counter. If you would like to delete an existing counter, click on that counter to select it, then press the trash icon to the top left. 39 + 40 +=== Properties === 41 + 42 +Select a counter by clicking on it in the list of counters to the left. The following details are shown for the counter: 43 + 44 +; {{smallcaps}}Uuid{{/smallcaps}} 45 +: A unique {{smallcaps}}id{{/smallcaps}} of the counter. You need to use this {{smallcaps}}Uuid{{/smallcaps}}, for example, when you want to retrieve the counter's current value via an {{smallcaps}}Ajax{{/smallcaps}} request, see also the servlet action plugin below. 46 +; Current value 47 +: The current value of the counter. 48 +; Creation date 49 +: The date when the counter was created. 50 +; Last change 51 +: The date of the most recent change to the counter's value. 52 + 53 +Additionally, you can also edit the following properties of a counter: 54 + 55 +; Counter name 56 +: The name of this counter. When you change the name of a counter, you may have to change existing //Variable// action, placeholders and {{smallcaps}}Ajax{{/smallcaps}} requests that reference a counter by its name. {{smallcaps}}Ajax{{/smallcaps}} requests that reference a counter by its {{smallcaps}}Uuid{{/smallcaps}} do not have to be updated. 57 +; Description 58 +: An optional description of this counter. This description is shown only within this backend menu. 59 +; Initial value 60 +: The initial value of this counter. This is also the value that is used when a workflow action resets a counter to its initial value. 61 +; Reset automatically 62 +: When this option es enabled, the value of this counter is reset in period intervals. 63 + 64 +=== Reset automatically === 65 + 66 +The following settings are available when the option to reset the counter automatically is enabled: 67 + 68 +{{info}} 69 + When a counter is reset, then after the counter action was processed, the counter's value will be equal to the configured initial value. For example: Assume the counter action was configured to increment the counter by //3// each time it is executed, and should be reset daily. Let the the current counter value be //37// and the intial value //11//. The first counter action that is executed on a new day will now reset the counter to //11//, and not be incremented at all. Starting with the second counter action of that day, the counter will be incremented by //3// each time the action is executed. 70 +{{/info}} 71 + 72 +{{info}} 73 + Please note that the counter is not reset by background task, but only when the workflow action //Counter// or //Variable// is executed. Or, to be more precise, the counter value is reset (instead of being incremented or decremented), when the time points at which the counter should have been reset contains at least one point that lies between the last point in time the counter value was modified and the current point in time. 74 +{{/info}} 75 + 76 +; Condition 77 +: Lets you choose when and how the counter should be reset. The following options are available: 78 +:; Counter greater than or equal 79 +:: Available only when the counting action was set to //count up//. The counter is reset to its initial value when, after the counter was incremented, its value is now greater than or equal to the given limit. 80 +:; Counter less than or equal 81 +:: Available only when the counting action was set to //count down//. The counter is reset to its initial value when, after the counter was decremented, its value is now less than or equal to the given limit. 82 +:; daily 83 +:: The counter is reset each day at the given time of day. 84 +:; weekly 85 +:: The counter is reset at each of the given days of the week and at the given time of the day. 86 +:; monthly 87 +:: The counter is reset each month at the given date and time of the day. 88 +:; yearly 89 +:: The counter is reset each year the given day, month and time of the day. 90 + 91 +== Workflow action "Counter" == 92 + 93 +{{figure image="plugin_dbcounter_action_counter_en.png"}} 94 + The settings for the workflow action //Counter//. You can select the counter to modify and how its value should be changed, e.g. incrementing or decrementing it by a certain amount. 24 24 {{/figure}} 25 25 26 -; 1 - Counter name 27 -: Name of the counter to be modified. For each counter you can see its name as well as its UUID. The UUID uniquely identifies a counter and is used when querying it via an AJAX request. To delete a counter, first select the counter, then click on the thrash icon to the right. To add a counter, first click on the plus icon, then enter a name for the new counter, and finally save the counter by pressing the floppy disc icon. 28 -; 2 - Counting action 97 +Once the plugin is installed, you can select the new action //Counter// in the [[workflow processing configuration>>doc:Formcycle.UserInterface.MyForms.WorkflowProcessing.WebHome]]. This action lets you modify the value of a predefined counter. 98 + 99 +Compared with the action //Variable//, here you need to select a predefined counter. You should have created this counter in the counter configuration menu (see above). Use this action when you need a global, non-dynamic counter, such as when you want to generate an identifier for each form record. 100 + 101 +; Counter name 102 +: Name of the counter to be modified. For each counter you can see its name as well as its {{smallcaps}}Uuid{{/smallcaps}}. The {{smallcaps}}Uuid{{/smallcaps}} uniquely identifies a counter and is used when querying it via an {{smallcaps}}Ajax{{/smallcaps}} request. To delete a counter, first select the counter, then click on the thrash icon to the right. To add a counter, first click on the plus icon, then enter a name for the new counter, and finally save the counter by pressing the floppy disc icon. 103 +; Counting action 29 29 : Lets you chose how the value of the counter should be changed. Possible options are: 30 30 :; Increment count 31 31 :: Adds the given amount to the current value of the counter. ... ... @@ -33,147 +33,229 @@ 33 33 :: Substracts the given amount from the current value of the counter. 34 34 :; Reset counter to start value 35 35 :: Sets the current value of the counter back to the selected initial value. 36 -; 3 -Step size111 +; Step size 37 37 : Amount by which the counter is incremented or decremented. 38 -; 4 - Initial value 39 -: The intial starting value of the counter. This is the value of the counter when it is first created. You may also reset the counter to this value. 40 -; 5 - Reset automatically 41 -: When this option is enabled, the counter is reset automatically by the system when certain conditions are met; such as each week, or when the counter value reaches a certain limit. See below for how to configure this feature. 113 +; Use global settings (deprecated) 114 +: You should leave this option checked and configure the counter settings in the counter configuration menu (see above). It exists only to ensure backwards compatibility with older versions of the plugin and may be removed in future versions. 42 42 43 -== =Resetautomatically===116 +== Workflow action "Variable" == 44 44 45 -{{figure image="dbcounter_ plugin_action_reset_greater_or_equal_en.png"}}46 - Configurationforresettinga counterwhen itsvalue exceed agiven limit.118 +{{figure image="plugin_dbcounter_action_variable_en.png"}} 119 + Settings for the workflow action //Variable//. It lets you select a counter dynamically by its name. You can also make use of placeholder variables to select a counter based on the value of some form field. 47 47 {{/figure}} 48 48 49 -{{figure image="dbcounter_plugin_action_reset_daily_en.png"}} 50 -Configuration for resetting a counter on a daily basis. 51 -{{/figure}} 122 +Once the plugin is installed, you can select the new action //Variiable// in the [[workflow processing configuration>>doc:Formcycle.UserInterface.MyForms.WorkflowProcessing.WebHome]]. This action lets you select a counter by its name and modify its value. 52 52 53 -{{figure image="dbcounter_plugin_action_reset_weekly_en.png"}} 54 -Configuration for resetting a counter on a weekly basis. 55 -{{/figure}} 124 +Compared with the action //Counter//, here you do not have to choose a predefined counter. You can also use [[placeholder variables>>doc:Formcycle.UserInterface.Variables]] to select a counter based on the submitted form data. In case the counter does not exists yet, a new counter is created dynamically. 56 56 57 -{{figure image="dbcounter_plugin_action_reset_monthly_en.png"}} 58 -Configuration for resetting a counter on a monthly basis. 59 -{{/figure}} 126 +Use this action when you need different counters for each submitted form record. For example, if you have got a participation form where users can sign up for a certain date, you can use a counter for each date to keep track of the number of registered people for that date. The counter name could be formatted like //participants-year-month-day//. 60 60 61 -{{figure image="dbcounter_plugin_action_reset_yearly_en.png"}} 62 -Configuration for resetting a counter on a yearly basis. 63 -{{/figure}} 128 +=== Change variable === 64 64 65 -{{info}} 66 -When a counter is reset, then after the counter action was processed, its value will be equal to the configured initial value. For example: Assume the counter action was configured to increment the counter by 3 each time it is executed, and should be reset daily. Let the the current counter value be //39// and the intial value //11//. The first counter action that is executed on a new day will now reset the counter to //11//, and not be incremented at all. Starting with the second counter action of that day, the counter will be incremented by //3// each time the action is executed.{{/info}} 130 +Select the name of the variable ("counter") to modify and how its value should be changed. 67 67 68 -A counter may be reset either in regular intervals or when its value exceeds a certain threshold. This feature is available only if the checkbox //reset automatically// was enabled and the counting action was not set to //Reset counter to start value//. 132 +; Counter name 133 +: Name of the counter to modify. Enter name of the counter, not its {{smallcaps}}Uuid{{/smallcaps}}). You can also use [[placeholder variables>>doc:Formcycle.UserInterface.Variables]] to select a counter based on a submitted form field. 134 +; Counting action 135 +: Lets you chose how the value of the counter should be changed. Possible options are: 136 +:; Increment count 137 +:: Adds the given amount to the current value of the counter. 138 +:; Decrement count 139 +:: Subtracts the given amount from the current value of the counter. 140 +:; Reset counter to start value 141 +:: Sets the current value of the counter back to the selected initial value. 142 +; Step size 143 +: Amount by which the counter is incremented or decremented. 69 69 70 - Regardingresetting the counter in daily intervals:Pleasenotethat the counterisnot reset by background task,but only when the workflowaction //counter// is executed. Or, to be more precise, the countervalue isreset (instead ofbeingincrementedr decremented), when the time pointsat which the counter should have been resetcontains at least one point that liesbetween the lastpoint in timehecounter value was modified and the current point in time.145 +=== Default settings if variable does not exists yet === 71 71 72 -; 1 - Bedingung 73 -: Hier kann festgelegt werden, wann und unter welchen Umständen der Zähler zurückgesetzt werden soll. 74 -:; Zähler größer gleich 75 -:: Nur verfügbar, wenn als Zählaktion //Hochzählen// gewählt wurde. Der Zähler wird auf den Startwert zurückgesetzt, wenn durch die aktuelle Aktion der Wert des Zählers so geändert wird, dass dieser größer oder gleich dem in (2) festgelegten Wert ist. 76 -:; Zähler kleiner gleich 77 -:: Nur verfügbar, wenn als Zählaktion //Herunterzählen// gewählt wurde. Der Zähler wird auf den Startwert zurückgesetzt, wenn durch die aktuelle Aktion der Wert des Zählers so geändert wird, dass dieser kleiner oder gleich dem in (2) festgelegten Wert ist. 78 -:; täglich 79 -:: Der Zähler wird jeden Tag zur bei (2) gewählten Uhrzeit auf den Startwert zurückgesetzt. 80 -:; wöchentlich 81 -:: Der Zähler wird an jedem unter (2) gewählten Wochentag zu der unter (3) gewählten Uhrzeit zurückgesetzt. 82 -:; monatlich 83 -:: Der Zähler wird jeden Monat zum unter (2) gewählten Tag zu der unter (3) gewählten Uhrzeit zurückgesetzt. 84 -:; jährlich 85 -:: Der Zähler wird jedes Jahr zum unter (2) und (3) gewählten Tag zu der unter (4) gewählten Uhrzeit zurückgesetzt 147 +In case the variable ("counter") with the given name does not exist yet, a new counter is created. Here you can edit the default settings for a newly created counter. In case the counter exists already, these settings do not have any effect. 86 86 87 -=== Allgemeine Rückgabeparameter === 149 +; Initial value 150 +: The initial value of the newly created counter. 151 +; Reset automatically 152 +: Whether the newly created counter should be reset automatically. When this option is enabled, a few more settings appear. See the section on the counter configuration menu above for further details. 88 88 89 -{{figure image="dbcounter_plugin_action_return_parameters_en.png"}} 90 -Einstellungen für die Rückgabeparameter, die später über Platzhalter verfügbar sind. 154 +== General return parameters == 155 + 156 +{{figure image="plugin_dbcounter_action_return_parameters_en.png"}} 157 +Settings for the return parameters of the counter action. You can access the returned values via placeholder variables. 91 91 {{/figure}} 92 92 93 - Manchmal istnotwendig,aufdenneuenZählwertzugreifenzukönnen.DieskannüberAktionsplatzhaltergeschehen, welcheuf die RückgabewerteeinerAktionzugreifen. In denallgemeinenRückgabeparameternkanneingestelltwerden,überwelchemSchlüsseldieRückgabeparameterAktionzugegriffenwerdenkann.BeispielsweisetragedieZähleraktiondenNamen//CountUp//.DannkannüberdenPlatzhalter//[%$CountUp.RESULT[0].count%]//aufdenaktuellenZählwertzugegriffenwerden,fallsunter(3)beidenlgemeinenRückgabeparameterderWert //count// eingetragenwurde.Folgende Rückgabeparametersindverfügbar:160 +Sometimes it may be necessary to access the new value of the counter. To do so, you can use [[action variables>>doc:Formcycle.UserInterface.Variables]] for accessing the returned values of an action. The section //general return parameters// lets you configure the key you need to use for accessing the return values. For example, assume a counter action were named //CountUp//. Then you can use the variable //[%$CountUp.RESULT[0].currentValue%]// to access the current counter value, provided you entered the key //currentValue// in the input field for the //Counter// return value. The following return values are available: 94 94 95 95 ; 1 - ResultCode 96 -: EinnummerischerZahlenwert, derangibt,ob dieZählaktion erfolgreichwaroder nicht.FolgendeErgebnisnummernsind möglich:163 +: A numerical value that indicates whether the counter action was successful or not. The following result codes are possible: 97 97 :; 1 (OK) 98 -:: DieZählaktion wurdeerfolgreich abgearbeitet.165 +:: The counter action was processed successfully. 99 99 :; 10 (UNKNOWN_ACTION_ERROR) 100 -:: DieZählaktionkannnichtausgeführtwerden,daeineunbekannteZählaktion ausgewähltwurde.Aktuellwerden dieZählaktionen//Hochzählen//, //Herunterzählen//und //Auf den Startwert zurücksetzen//unterstützt.167 +:: The counter action could not be processed, an unknown counting action was selected. The currently supported counting actions are //count up//, //count down// and //reset counter to start value//. 101 101 :; 11 (PARSING_ERROR) 102 -:: EinkonfigurierterWerthatnichtdenerwartetenDatentyp,etwa wennfürdieSchrittweitedesZählerskeinesyntaktischkorrekteZahleingegeben wurde.169 +:: A settings does not conform to the expected data type or syntax; such as when a letter was entered for the initial value (instead of a number). 103 103 :; 40 (INTERNAL_ERROR) 104 -:: EsistdererFehleraufgetreten,dernichtnäherklassifiziertwerdenkann.171 +:: The counter action was not successful. The type of error cannot be specified more closely. 105 105 ; 2 - ResultMessage 106 -: EineenglischeBeschreibungdesResultats(ErfolgoderFehler).173 +: An English description of the result (success or error). 107 107 ; 3 - Counter 108 -: DerneuenummerischeWertdesZählers,nachdemdieZählaktion ausgeführtwurde.175 +: The new numerical value of the counter, after the counting action was applied. 109 109 ; 4 - IsReset 110 -: E ntweder //true//,falls derZählerdurchdieaktuelleAktionzurückgesetztwurde; oder //false//,wennernichtzurückgesetzt wurde.177 +: Either //true//, when the counter was reset during the current action; or //false// if it was not reset. 111 111 ; 5 - CounterAfterReset 112 -: FallsderZählerzurückgesetztwurde:DernummerischeWertdesZählersvordemZurücksetzen.179 +: In case the counter was reset: The numerical value of the counter before the reset. 113 113 114 -== System platzhalter-Plugin ==181 +== System variable plugin == 115 115 116 116 {{figure image="dbcounter-plugin-placeholder_en.png"}} 117 - EinBeispiel fürdenPlatzhalterzum AuslesendesZählwerts. Hier wirdeinZähler ausgelesen,derdieAnzahlanAnmeldungenfüreineVeranstaltungzählt.Dannwird geprüft, ob derZählwertdie maximaleAnzahl an Anmeldungen übersteigt. BasierendaufdieserPrüfungkanndemNutzer danneinFehler angezeigtwerden,fallsdieVeranstaltungbereitsausgebuchtist.Hierbeihandeltssichumeine serverseitigePrüfungzur Validierung,bereits imFormularbeiderAnmeldungsollte demNutzernatürlichschondieInformationgegebenwerden,ob überhauptnochPlätze freisind.184 + An example for how to retrieve the current value of a counter. Here we read a counter that is used for keeping track of the number of participants of some event. We then check whether the value exceeds the maximum number of participants. Based on the result of this check, we can display an appropriate error message to the user in case the limit was reached. By performing this check during workflow processing, we can validate the data on the server and prevent manipulatios. Please note that it is best practice to give the user some feedback while the fill out the form and inform the user in case no more free slots are available. 118 118 {{/figure}} 119 119 120 - NachInstallationdesPluginsisteinneuer[[Systemplatzhalter>>doc:Formcycle.UserInterface.Variables]]verfügbar,überdenaufdenaktuellenWert einesZählerszugegriffenwerdenkann. Diesistetwanützlich,umineinerAktionsbedingungdenZählwertnutzen undprüfen zukönnen.DerPlatzhalterbautsichnachdemfolgendenSchemaauf:187 +Once the plugin is installed, you can access the current value of the plugin with a [[system variable>>doc:Formcycle.UserInterface.Variables]]. This can be used, for example, to access the counter value in the condition of a workflow action and compare it with a submitted value. The system variable has got the following pattern: 121 121 122 -{{code}} 123 -[%$DBCOUNTER.< Zählername>%]189 +{{code language="none"}} 190 +[%$DBCOUNTER.<CounterName>%] 124 124 {{/code}} 125 125 126 - Umalsoetwaauf denZählermitdemName //test//zuzugreifen,mussderfolgendePlatzhalter genutzt werden:193 +For example, in order to access the value of a counter named //test//, you can use the following variable: 127 127 128 -{{code}} 195 +{{code language="none"}} 129 129 [%$DBCOUNTER.test%] 130 130 {{/code}} 131 131 132 - ==Servlet-Aktions-Plugin==199 +In case you need to access a counter that may not exist yet, you need to provide an initial value for the counter. When the counter does not exist yet, a new counter with the given initial value is created. Use the following pattern: 133 133 201 +{{code language="none"}} 202 +[%$DBCOUNTER(<CounterName>, <InitialValue>)%] 203 +{{/code}} 204 + 205 +For example, if the counter is named //participants-2020-03-17// and should start at //0// in case it does not exist, you can use the following variable: 206 + 207 +{{code language="none"}} 208 +[%$DBCOUNTER(participants-2020-03-17, 0)%] 209 +{{/code}} 210 + 211 +== Servlet action plugin == 212 + 134 134 {{figure image="dbcounter_plugin_servlet_action.png"}} 135 - BeispielzumAuslesen einesZählers imFormularmittelsAJAX.Die URL wirdanhandderimFormularzurVerfügung stehendenMetadatenaufgebaut.Hiermitwird vermieden,die URL hart imQuelltextzuhinterlegen,waszuFehlern führt, wennsichtwaderServeroderder Kontextpfadändernsollte.214 + An example for how the counter value can be accessed via an {{smallcaps}}Ajax{{/smallcaps}} request. The {{smallcaps}}Url{{/smallcaps}} is build with the metadata available in the form context. This avoids having to enter the {{smallcaps}}Url{{/smallcaps}} directly in the code, which is prone to error: the host or context path could change, for example, when the form is moved between a development and production. 136 136 {{/figure}} 137 137 138 -Nach Installation des Plugins ist eine neue Servlet-Aktion verfügbar, mit der auf den aktuellen Wert eines Zähler zugegriffen werden kann. Dies ist etwa nützlich, wenn aus dem Formular heraus ein Zählwert per AJAX-Anfrage abgerufen werden soll. Die URL für das Servlet baut sich nach dem folgenden Schema auf: 139 139 140 -{{code}} 141 -https://<HOST>/<FORMCYCLE_CONTEXT_PATH>/plugin?name=Servlet%20Counter&client-id=<MANDANT_ID>&id=<ZAEHLER_UUID> 218 +Once the plugin is installed, a new servlet plugin action is available that lets you access the current value of a counter via an {{smallcaps}}Http{{/smallcaps}} request. This is useful, for example, when you would like to read the counter's current value from within a form and display it in the form. The {{smallcaps}}Url{{/smallcaps}} for the counter action plugin servlet takes the following pattern: 219 + 220 +{{code language="none"}} 221 +https://<Host>/<FormcycleContextPath>/plugin?name=Servlet%20Counter&client-id=<ClientId>&id=<CounterUuid> 142 142 {{/code}} 143 143 144 - FallsalsoetwaFORMCYCLElokal unterdemPfad//xima-formcycle//installiertwurde, derZählerineinemProjektdes MandantenmitderID//1//verwendetwird unddieUUID//bc49d3b0-f869-4e59-864e-ddcc2925ed63//besitzt,dannlautetdie URL:224 +Assuming {{formcycle/}} was installed locally and runs in the context path //formcycle//, and the counter plugins was installed within a client with the {{smallcaps}}id{{/smallcaps}} //1//, and the {{smallcaps}}Uuid{{/smallcaps}} of the counter is //bc49d3b0-f869-4e59-864e-ddcc2925ed63//, the {{smallcaps}}Url{{/smallcaps}} is: 145 145 146 -{{code}} 147 -https://localhost:8080/ xima-formcycle/plugin?name=Servlet%20Counter&client-id=1&id=bc49d3b0-f869-4e59-864e-ddcc2925ed63226 +{{code language="none"}} 227 +https://localhost:8080/formcycle/plugin?name=Servlet%20Counter&client-id=1&id=bc49d3b0-f869-4e59-864e-ddcc2925ed63 148 148 {{/code}} 149 149 150 -Alternativ istesauch möglich,stattder//client-id//dieIDdesFormularszu verwenden. Diese IDslediglichverwendet,umdasServlet-Aktions-Pluginzubestimmen,welchesausgeführtwerdensoll,und werdenvondiesemkonkretenPlugin nicht ausgewertet:230 +Alternatively, you can also use the {{smallcaps}}id{{/smallcaps}} of the form instead of the //client-id//. Both the client and the form {{smallcaps}}id{{/smallcaps}} are used only to identify the servlet to be executed; and are not used in any way by this counter servlet. 151 151 152 -{{code}} 153 -https://<H OST>/<FORMCYCLE_CONTEXT_PATH>/plugin?name=Servlet%20Counter&project-id=<FORMULAR_ID>&id=<ZAEHLER_UUID>232 +{{code language="none"}} 233 +https://<Host>/<FormcycleContextPath>/plugin?name=Servlet%20Counter&project-id=<FormID>&id=<CounterUuid> 154 154 {{/code}} 155 155 156 - NachAusführung des Servlet-Aktions-Pluginwird das Ergebnisals JSON-Objektzurückgeliefert,siehe hierzu auch die Abbildung. Dieses JSON-Objekt hat die folgenden Einträge:236 +=== HTTP parameter === 157 157 238 +In addtional to the parameters mentioned above, you can also specify a few more paramters as {{smallcaps}}Url{{/smallcaps}} parameters. The following is an overview of all available parameters. 239 + 240 +; name 241 +: The name of the servlet plugin action to execute. Set this to //Servlet Counter// for this plugin. 242 +; client-id 243 +: {{smallcaps}}id{{/smallcaps}} of the client where the counter plugin was installed. Not required in case the plugin was installed as a system plugin. Only one of //client-id// or //project-id// may be specified. 244 +; project-id 245 +: {{smallcaps}}id{{/smallcaps}} of a form that belongs to a client that has access to the counter plugin., in dem das Zähler-Plugin zur Verfügung steht. Only one of //client-id// or //project-id// may be specified. 246 +; id 247 +: {{smallcaps}}Uuid{{/smallcaps}} of counter to read. In case a counter with the given {{smallcaps}}Uuid{{/smallcaps}} does not exist yet, a corresponding error code is returned, see below. Only one of //id// or //counter-name// may be specified. 248 +; counter-name 249 +: Name of the counter to read. In case a counter with the given name does not exist yet, a new counter is created with the given initial value.Only one of //id// or //counter-name// may be specified. 250 +; counter-initial 251 +: Optional. The initial value of the counter, in case it does not exist yet. Defaults to //0//. This parameter is allowed only when //counter-name// is specified. 252 +; counter-array 253 +: Optional. Either //true// or //false//, defaults to //false//. When this is set to //true//, the parameter //counter-name// or //id// may be specified multiple times. This will return an array with the current value of all specified counters. This can be used, for example, to reduce the amount of {{smallcaps}}Http{{/smallcaps}} requests when you need to query multiple counter simultaneously. 254 + 255 +=== HTTP response === 256 + 257 +If the servlet action plugin is executed successfully, it returns a {{smallcaps}}Json{{/smallcaps}} object as shown in the figure to the right. When the parameter //counter-array// was set to //true//, a {{smallcaps}}Json{{/smallcaps}} array is returned instead, with each item being a {{smallcaps}}Json{{/smallcaps}} object as described below. 258 + 259 +The {{smallcaps}}Json{{/smallcaps}}-Objekt has got the following properties: 260 + 158 158 ; Status 159 -: Gibtan, ob derServlet-Aufruferfolgreichwar.DerWertisteinweiteresJSON-Objektmit folgenden Einträgen:262 +: Indicates whether the servlet request was successful. The value is another {{smallcaps}}Json{{/smallcaps}} object with the following entries: 160 160 :; Msg 161 -:: Ein nummerischer Wert, der angibt, ob der Servlet-Aufruf erfolgreich war. Mögliche Werte sind: 162 -::; (OK) 163 -::; (NO_REQUEST_ID_ERROR) 164 -::; (NO_COUNTER_TO_UUID_ERROR) 264 +:: A numerical value that indicates whether the servlet request was successful. Possible values are: 265 +::; 0 (OK) 266 +::: The request was successful. 267 +::; 12 (NO_REQUEST_ID_ERROR) 268 +::: The request did not specify a counter UUID. 269 +::; 13 (NO_COUNTER_TO_UUID_ERROR) 270 +::: No counter with the specified UUID exists. 271 +::; 40 (INTERNAL_ERROR) 272 +::: The counter action was not successful. The type of error cannot be specified more closely. 165 165 :; Code 166 -:: EineenglischeBeschreibungdesResultats(ErfolgoderFehler).274 +:: An English description of the result (success or error). 167 167 ; Counter 168 -: Informationen zum angefragten Zähler. Der Wert ist ein weiteres JSON-Objekt mit folgenden Einträgen: 169 -: Der aktuelle nummerische Wert des Zählers. 276 +: Details about the requested counter. The value is another {{smallcaps}}Json{{/smallcaps}} object with the following entries: 170 170 :; LastChange 171 -:: DasDatum mitUhrzeit,andemder Zählerzuletzt geändertwurde.DasDatum wird mit demDatums- undZeitformatderaktuellenServer-Localeformattiert.278 +:: The date and time of the most recent modification of the counter value. The date and time is formatted according to the current server locale. 172 172 :; LastChangeTimestamp 173 -:: DasDatum mitUhrzeit,andemder Zählerzuletzt geändertwurde.DerZeitstempelisteine ganzeZahl, welchedieAnzahlanMillisekundenseitdem 1.Januar, 1970, 00:00:00 GMTangibt.280 +:: The date and time of the most recent modification of the counter value. The timestamp is a whole number indicating the number of milliseconds January 1st, 1970, 00:00:00 GMT. 174 174 :; Value 175 -:: DeraktuellenummerischeWertdesZählers.282 +:: The current numerical value of the counter. 176 176 :; UUID 177 -:: Die UUIDdes angefragtenZählers,dessen Wert ausgelesenwurde.284 +:: The UUID of the requested counter. 178 178 :; Name 179 -:: Der Name des angefragten Zählers, dessen Wert ausgelesen wurde. 286 +:: The name of the requested counter. 287 + 288 +== Changelog == 289 + 290 +This section lists all known versions of this plugin and describes the changes that were made in each version. 291 + 292 +=== 2.3.3 === 293 + 294 +* Fixed some spelling mistakes 295 + 296 +=== 2.3.2 === 297 + 298 +* Fixed a UI bug: The checkbox //Use global settings// (action //Counter//) now toggles the options below correctly. 299 +* Fixed some spelling mistakes 300 + 301 +=== 2.3.1 === 302 + 303 +* Fixed a bug with {{smallcaps}}Mysql{{/smallcaps}} that prevented this plugin from working with that database management system. 304 + 305 +=== 2.3.0 === 306 + 307 +* New action: //Variable// 308 +* Lets you select a counter by its name and allows for placeholder variables. This requires an initial value. 309 +* New placeholder variable: //DBCOUNTER(name, initialValue)//. Creates a new counter in case a counter with the given name does not exist yet. 310 +* Added 3 new parameters to the servlet action plugin: //counter-name//, //counter-initial// and //counter-array//. 311 + 312 +=== 2.2.0 === 313 + 314 +* Make sure to reset the counter even when its value is only read 315 +* Portal page that adds a new menu entry to the backend: Counter configuration 316 +* Deprecate editing a counter's settings in the workflow action directly 317 + 318 +=== 2.1.0 === 319 + 320 +* Modifications for {{formcycle/}} version 6.1.6 321 +* The //CounterPlugin// and //ServletCounterPlugin// had the same name, this resulted in errors 322 +* Fixed an error that resulted in a counter not being resetted correctly 323 +* Add a new property to the {{smallcaps}}Json{{/smallcaps}} object returned by the servlet action plugin: //Counter.LastChangeTimestamp// 324 +* Added a new system variable replacer plugin that lets you access the value of a counter via a variable: //[%DBCOUNTER.name%]// 325 + 326 +=== 2.0.0 === 327 + 328 +* Modifications to make the plugin work with {{formcycle/}} version 6.0.2 329 + 330 +=== 1.0.1 === 331 + 332 +* Fix a bug where the counter value was not set when retrieved for the first time 333 + 334 +=== 1.0.0 === 335 + 336 +* Initial version