How to count current records and use it as a value
Asked by Ilcin:

Hi,

I want to do a simple waiting List with Confiforms and thought about giving the people their placements depending on the current number of entries.  
(If there are 5 entries the next entry should have placement number of entries +1)

Is that possible?  
Is there a way to count the number of current entries and store them in a Definition value for example with a definition rule?  
Thinking further: How can I make sure that if a record is deleted the Placements are recalculated correctly?

<br />

Or are there any other ways to accomplish this?

Thanks!


Answers:
author: Alex Medved _ConfiForms_
body: Consider the following example in Confluence storage format (a prototype, and this has not been tested in highly concurrent environments and it **will NOT work with deletes**)

So, I have a form with ConfiForms IFTTT action which updates an internal field with the value of a "_count" variable from the context

```
entryId=[entry.id]&nr=[entry._count]
```

<https://wiki.vertuna.com/display/CONFIFORMS/Accessing+field+values+and+properties#Accessingfieldvaluesandproperties-Additionalvaluesavailableinthecontext>

```
<ac:structured-macro ac:macro-id="d9d85f19-f39a-4d57-ac67-7217d4e98caa" ac:name="confiform" ac:schema-version="1">
<ac:parameter ac:name="formName">form</ac:parameter>
<ac:rich-text-body>
<ac:structured-macro ac:macro-id="cabcdb34-26ad-44c9-87ee-4f2df3d24cd3" ac:name="confiform-entry-register" ac:schema-version="1">
<ac:parameter ac:name="formName">form</ac:parameter>
<ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p>
<ac:structured-macro ac:macro-id="47589e7c-4690-45ff-809c-380a4506a68a" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">nr</ac:parameter>
<ac:parameter ac:name="fieldLabel">nr</ac:parameter>
<ac:parameter ac:name="type">hidden</ac:parameter>
</ac:structured-macro>
</p>
<ac:structured-macro ac:macro-id="4d56e543-bb05-44d0-a178-3c41930fdcd6" ac:name="confiform-ifttt" ac:schema-version="1">
<ac:parameter ac:name="action">Create ConfiForms Entry</ac:parameter>
<ac:parameter ac:name="event">onCreated</ac:parameter>
<ac:parameter ac:name="title">entryId=[entry.id]&amp;nr=[entry._count]</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
</ac:rich-text-body>
</ac:structured-macro>
<p>
<br/>
</p>
<p>
<br/>
</p>
<ac:structured-macro ac:macro-id="561a6b5b-12a1-4d96-89dc-d000dc2f0318" ac:name="confiform-card" ac:schema-version="1">
<ac:parameter ac:name="messageToShowWhenEmpty">No data yet</ac:parameter>
<ac:parameter ac:name="formName">form</ac:parameter>
<ac:rich-text-body>
<p>
<ac:structured-macro ac:macro-id="8cec63f4-010d-4a0d-b7a6-e48537aeb097" ac:name="confiform-field" ac:schema-version="1">
<ac:parameter ac:name="fieldName">nr</ac:parameter>
</ac:structured-macro>
</p>
</ac:rich-text-body>
</ac:structured-macro>
```

You can import this format with [Confluence source editor](https://marketplace.atlassian.com/apps/1210722/confluence-source-editor?hosting=server&tab=overview) - free app from Atlassian


Tags: addon-com.vertuna.confluence.plugins.confiforms

confiforms

count

list