virtual function in random results

kimiya majd February 9, 2020

I have a virtual function in random results in a confiforms tableview and when I refresh the page give me a null result and I don't wanna this, i want to give some results in a row field in my form. ???!

(row:[entry._total.randomInt(14)] OR row:([entry._total.randomInt(14)]+[entry._total.randomInt(14)]) OR row:[entry._total.randomInt(14)]*[entry._total.randomInt(14)]) AND date:1

 

1 answer

1 vote
Alex Medved _ConfiForms_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 9, 2020

Hi

 

it looks like a question about ConfiForms (and this is a plugin for Confluence, not Jira)

 

Anyway, could you tell me what this expression is supposed to do? What do  you expect?

kimiya majd February 9, 2020

Hi

yes , thanks for your attention

I want to create a lottery form in confluence with confiforms and i search about it and says write virtual function to give a random result and i do that but now when i refresh the page in so many times I recieve the null results and I don't want this . you know about it ?

Alex Medved _ConfiForms_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 9, 2020

Here is an example of how randomInt can be used (3 variants)

https://recordit.co/ujjsS8w0ca

So, we set the max (as base and set it to 100 (for example)) and then set randomIn(1), so 1 is the minimum possible

3 variants: one via formula field, 2nd via the field definition rule and 3rd one is online calculation in the view (each time new value on refresh)

Storage format

<ac:structured-macro ac:macro-id="6be21c12-9b20-4c2f-8607-808f3996527b" ac:name="confiform" ac:schema-version="1">
<ac:parameter ac:name="formName">myform</ac:parameter>
<ac:rich-text-body>
<ac:structured-macro ac:macro-id="ce6eeec2-0049-4e3c-9992-91571c93e7ba" ac:name="confiform-entry-register" ac:schema-version="1">
<ac:parameter ac:name="formName">myform</ac:parameter>
<ac:parameter ac:name="presetValues">base=100</ac:parameter>
<ac:parameter ac:name="type">Embedded</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="d76ba27e-c2fc-4a8b-bfe6-3b54712a4211" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">base</ac:parameter>
<ac:parameter ac:name="fieldLabel">Base</ac:parameter>
<ac:parameter ac:name="type">numberhidden</ac:parameter>
</ac:structured-macro>
</p>
<p>
<br/>
</p>
<p>-- 1st variant</p>
<p>
<ac:structured-macro ac:macro-id="0c8b9ddf-56ab-40ec-869c-c0f41d8ba725" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">random</ac:parameter>
<ac:parameter ac:name="fieldLabel">Random</ac:parameter>
<ac:parameter ac:name="extras">([entry.base.randomInt(1)])</ac:parameter>
<ac:parameter ac:name="type">formula</ac:parameter>
</ac:structured-macro>
</p>
<p>-- 2nd variant</p>
<p>
<ac:structured-macro ac:macro-id="e3f2ff8f-3609-43b4-8b0d-80c3c5f3dc76" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">random2</ac:parameter>
<ac:parameter ac:name="fieldLabel">Random via rule</ac:parameter>
<ac:parameter ac:name="type">number</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="5c73563c-18e8-4ccb-9c75-b69381b6165b" ac:name="confiform-field-definition-rules" ac:schema-version="1">
<ac:parameter ac:name="values">random2=([entry.base.randomInt(1)])</ac:parameter>
<ac:parameter ac:name="action">Set expression</ac:parameter>
</ac:structured-macro>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p>
<br/>
</p>
<p>– 3rd variant</p>
<ac:structured-macro ac:macro-id="08ab3946-411c-47c6-81fb-500ad2ed638d" ac:name="confiform-table" ac:schema-version="1">
<ac:parameter ac:name="formName">myform</ac:parameter>
<ac:rich-text-body>
<p>
<ac:structured-macro ac:macro-id="52a91fd9-afcd-446c-a38f-33dfb39a3d8d" ac:name="confiform-field" ac:schema-version="1">
<ac:parameter ac:name="fieldName">random</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="0b89d904-0b72-4340-a5a6-582772d8cd8a" ac:name="confiform-field" ac:schema-version="1">
<ac:parameter ac:name="fieldName">random2</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="6b7571d9-9508-4c91-97dd-85244829c622" ac:name="confiform-field" ac:schema-version="1">
<ac:parameter ac:name="overrideLabel">Random3 online</ac:parameter>
<ac:parameter ac:name="fieldName">base.randomInt(1)</ac:parameter>
</ac:structured-macro>
</p>
</ac:rich-text-body>
</ac:structured-macro>
Like kimiya majd likes this
kimiya majd February 10, 2020

thank you 

it's so helpful

but my rows aren't sorted regularly and my records in my form aren't Continuous and i don't want to have a null result but now i refresh it, i give a null in many times. 

what should I do?

Alex Medved _ConfiForms_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 10, 2020

Probably you need to fix your configuration based on the examples I have given you earlier...

Not sure what else I can answer here....

Like kimiya majd likes this

Suggest an answer

Log in or Sign up to answer