How to use generateUUID Virtual functions in Confiform

Rauzan Fikri May 7, 2023

Hi @Alex Medved _ConfiForms_ 

 

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.

2 comments

Rauzan Fikri May 7, 2023

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

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.
May 7, 2023

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

Like Rauzan Fikri likes this
Rauzan Fikri May 7, 2023

Hi @Alex Medved _ConfiForms_ 

 

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

Rauzan Fikri May 7, 2023

Also I just realize we can call the virtual function method via _func

 

Awesome !

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.
May 7, 2023

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

Like Rauzan Fikri likes this

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events