How to use generateUUID Virtual functions in Confiform
Asked by Rauzan Fikri:

Hi [@Alex Medved _ConfiForms_](https://community.atlassian.com/t5/user/viewprofilepage/user-id/781630)

May I know how to user generateUUID Virtual functions in Confiform, we just updating our confiform version to 3.4.3 and a bit confusing how to user this function.

Also of course many thanks for this a new virtual function, this function is will help us to generate the token or randomize value.


Answers:
author: Alex Medved _ConfiForms_
body: Yes, when you attempt to use a function on an empty field then it will obviously not work. As the expression evaluation stopes on the empty value.

You need to use the _func or some field that has a value, for example an "id" field (which has a value after submission - you cannot use it in the form view in UI for new records, as the record is still unsaved)

Alex


author: Rauzan Fikri
body: Also I just realize we can call the virtual function method via _func

Awesome !


author: Rauzan Fikri
body: Hi [@Alex Medved _ConfiForms_](/t5/user/viewprofilepage/user-id/781630)

Previously the function doesn't want to work because my code is not correct when trying to set the uuid value into a field via iftt.

previous code

fieldA = \[entry.fieldA.generateUUID\] (the previous value of fieldA is empty)

then change the code to

fieldA = \[entry.id.generateUUID\] (the field id always having value)

we assuming the problem is because we trying to generate the uuid value from empty field.

Thanks Alex for the function, this's really help


author: Alex Medved _ConfiForms_
body: Hi

What is not working for you and what have you tried?

Using this virtual function is no different to using any other virtual function ConfiForms has to offer

Little demo: <http://recordit.co/ShI3YkNvoi>

And the complete configuration for the reference:

```
<ac:structured-macro ac:macro-id="19d371ac-8613-40cc-85ca-bda73eb6b34d" ac:name="confiform" ac:schema-version="1">
<ac:parameter ac:name="formName">f</ac:parameter>
<ac:rich-text-body>
<ac:structured-macro ac:macro-id="4f216335-970b-489b-8f68-4d20e083865c" ac:name="confiform-entry-register" ac:schema-version="1">
<ac:parameter ac:name="presetValues">viaPreset=[entry._func.generateUUID]</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p>
<ac:structured-macro ac:macro-id="606b3b45-39c3-468f-8f47-eef160cbc063" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">viaPreset</ac:parameter>
<ac:parameter ac:name="fieldLabel">Via Preset</ac:parameter>
<ac:parameter ac:name="type">read_only</ac:parameter>
</ac:structured-macro>
</p>
<p>
<br/>
</p>
<p>
<ac:structured-macro ac:macro-id="f97a9a94-a6af-4e04-ac6d-7dbbde843ce4" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">c</ac:parameter>
<ac:parameter ac:name="fieldLabel">Set UUID via rule</ac:parameter>
<ac:parameter ac:name="type">checkbox</ac:parameter>
</ac:structured-macro>?<ac:structured-macro ac:macro-id="87980e82-f650-4507-9cdc-8a91f6eaccc0" ac:name="confiform-field-definition-rules" ac:schema-version="1">
<ac:parameter ac:name="condition">c:true</ac:parameter>
<ac:parameter ac:name="values">viaUIRule=[entry._func.generateUUID]</ac:parameter>
<ac:parameter ac:name="action">Set value</ac:parameter>
<ac:parameter ac:name="actionFieldName">c</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="3659aba6-34c3-41dc-bff9-1fdd5f4281cd" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">viaUIRule</ac:parameter>
<ac:parameter ac:name="fieldLabel">Via UI Rule</ac:parameter>
<ac:parameter ac:name="type">read_only</ac:parameter>
</ac:structured-macro>?</p>
<p>
<br/>
</p>
<p>
<ac:structured-macro ac:macro-id="dbfb8a47-e490-44d8-bbec-5d5566436c64" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">roUpdatedWithIFTTT</ac:parameter>
<ac:parameter ac:name="fieldLabel">Read-only and updated via IFTTT after submit</ac:parameter>
<ac:parameter ac:name="type">read_only</ac:parameter>
</ac:structured-macro>
</p>
<p>
<br/>
</p>
<ac:structured-macro ac:macro-id="053dd0ea-fa94-43d5-abc7-64735e8af49c" ac:name="confiform-ifttt" ac:schema-version="1">
<ac:parameter ac:name="extras3">true</ac:parameter>
<ac:parameter ac:name="extras4">true</ac:parameter>
<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;roUpdatedWithIFTTT=[entry._func.generateUUID]</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p>
<br/>
</p>
```

Hope it helps

Alex


author: Rauzan Fikri
body: Seems this function is not working when field type is hidden or readonly, current we are trying to using this function via iftt or rules of Rules for Field Definition


Tags: confiforms

confluence-server

server

uuid