I have a form with a checkbox group 'choices' which has two entries:
ID Value
1 Choice1
2 Choice2
In a field definition rule I can test each checkbox easily using i.e. choice:1, but when I try to access the content in the macro body this doesn't seem possible. I can get a list of all the choices selected (either ID or value) readily enough, however I don't seem to be able to reference a single checkbox. For example [entry.choices.Choice1] returns all selected ID's (i.e. "1 2" if both selected)
Is there a syntax similar to [entry.choices:1] I can use in a macro body?
For the time being JS like the following but it's not usable beyond 9 numeric ID's and a bit verbose so would prefer to use supported access methods:
if ('[entry.choices.ID]'.includes('1')) { do stuff }
Using "[entry.choices.Choice1]" you are making a reference to the field's value(s)
Entry does not know about other choices the field (definition), that manages this entry, has.
You can always access the field in UI via the Field Definition Rule and executing JavaScript
See "Running custom JavaScript" section https://wiki.vertuna.com/display/CONFIFORMS/ConfiForms+Field+Definition+Rules
Hi @Alex Medved _ConfiForms_ - I must be doing something very basically wrong because I can't get the JS to execute
Also once I do I am not clear on how test for specifc group check box options (but one step at a time)
<p>
<ac:structured-macro ac:macro-id="8c473405-34c7-4f3b-b5d6-ff73f5f0f65c" ac:name="confiform-entry-register" ac:schema-version="1">
<ac:parameter ac:name="formName">Form1</ac:parameter>
<ac:parameter ac:name="registrationButtonLabel">Option 1</ac:parameter>
<ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter>
<ac:rich-text-body>
<ac:structured-macro ac:macro-id="50905e94-92b3-4eb2-8124-8313e6950df7" ac:name="confiform-field" ac:schema-version="1">
<ac:parameter ac:name="fieldName">F1</ac:parameter>
<ac:parameter ac:name="withLabel">true</ac:parameter>
</ac:structured-macro>
</ac:rich-text-body>
</ac:structured-macro>
</p>
<ac:structured-macro ac:macro-id="70725982-a720-4e67-a8d9-2548153ae8b1" ac:name="confiform" ac:schema-version="1">
<ac:parameter ac:name="formName">Form1</ac:parameter>
<ac:rich-text-body>
<ac:structured-macro ac:macro-id="606ded1e-5d6d-4dbe-8ca3-ebe7e747b327" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">F1</ac:parameter>
<ac:parameter ac:name="fieldLabel">choose wisely</ac:parameter>
<ac:parameter ac:name="values">false[1=One|2=Two|]</ac:parameter>
<ac:parameter ac:name="extras">on</ac:parameter>
<ac:parameter ac:name="type">checkbox_group</ac:parameter>
</ac:structured-macro> <ac:structured-macro ac:macro-id="2ccd6e05-998d-443a-8103-11f6886a5e3a" ac:name="confiform-field-definition-rules" ac:schema-version="1">
<ac:parameter ac:name="condition">!F1:[empty]</ac:parameter>
<ac:parameter ac:name="values">Show([entry.F1]);</ac:parameter>
<ac:parameter ac:name="action">Run custom JavaScript</ac:parameter>
<ac:parameter ac:name="onUserActionOnly">true</ac:parameter>
<ac:parameter ac:name="actionFieldName">F1</ac:parameter>
</ac:structured-macro>
</ac:rich-text-body>
</ac:structured-macro>
<ac:structured-macro ac:macro-id="978f7a22-90f6-4ae1-b735-7887126f8e37" ac:name="html" ac:schema-version="1">
<ac:plain-text-body><![CDATA[<script>
function Show(group) {
// never execute it in edit mode
if (isPageViewMode()) {
alert('hi!');
}
}
</script>]]></ac:plain-text-body>
</ac:structured-macro>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I removed the code which allegedly stops the JS being executed in edit mode and thing started to work - you might want to update the wiki content if this is no longer valid?
Storage format below
<p>
<ac:structured-macro ac:macro-id="8c473405-34c7-4f3b-b5d6-ff73f5f0f65c" ac:name="confiform-entry-register" ac:schema-version="1">
<ac:parameter ac:name="formName">Form1</ac:parameter>
<ac:parameter ac:name="registrationButtonLabel">Option 1</ac:parameter>
<ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter>
<ac:rich-text-body>
<ac:structured-macro ac:macro-id="624cc5f6-19ba-495a-90a7-00241574f110" ac:name="confiform-field" ac:schema-version="1">
<ac:parameter ac:name="fieldName">F1</ac:parameter>
<ac:parameter ac:name="withLabel">true</ac:parameter>
</ac:structured-macro>
</ac:rich-text-body>
</ac:structured-macro>
</p>
<ac:structured-macro ac:macro-id="70725982-a720-4e67-a8d9-2548153ae8b1" ac:name="confiform" ac:schema-version="1">
<ac:parameter ac:name="formName">Form1</ac:parameter>
<ac:rich-text-body>
<ac:structured-macro ac:macro-id="1534027e-5292-43a3-adbc-454131ef3d20" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">F1</ac:parameter>
<ac:parameter ac:name="fieldLabel">choose wisely</ac:parameter>
<ac:parameter ac:name="values">false[1=One|2=Two|]</ac:parameter>
<ac:parameter ac:name="extras">on</ac:parameter>
<ac:parameter ac:name="type">checkbox_group</ac:parameter>
</ac:structured-macro> <ac:structured-macro ac:macro-id="e9e1e251-a677-4bc3-92b8-58f823392ac0" ac:name="confiform-field-definition-rules" ac:schema-version="1">
<ac:parameter ac:name="condition">F1:2</ac:parameter>
<ac:parameter ac:name="values">DoShow('option 2 selected');</ac:parameter>
<ac:parameter ac:name="action">Run custom JavaScript</ac:parameter>
<ac:parameter ac:name="onUserActionOnly">true</ac:parameter>
<ac:parameter ac:name="actionFieldName">F1</ac:parameter>
</ac:structured-macro>
</ac:rich-text-body>
</ac:structured-macro>
<ac:structured-macro ac:macro-id="978f7a22-90f6-4ae1-b735-7887126f8e37" ac:name="html" ac:schema-version="1">
<ac:plain-text-body><![CDATA[<script>
function DoShow(Message) {
alert(Message);
}
</script>]]></ac:plain-text-body>
</ac:structured-macro>
Not sure how this will help solve the problem I am trying to solve though. While I can call a JS fragment every time a specific checkbox group option gets set (or cleared) depending on what rule I set, what I really need to be able to do is to process all of the group checkboxes in one go when the form is submitted. I have a form with mutliple sections, and currently when the form is submitted I am generating content for a Jira ticket as table (wiki markup) including the values of all of the fields in the form like so:
| static text | [entry.field1.label | \n | static text | [entry.field2.label | \n (etc.)
What I want to do is process the fields in JS triggered by IFTTT macro to generate my content, and per the start of of this post got stuck on the group check boxes (also stuck on how to update the hidden field with the result of the JS, but that's a different topic I raised here)
If you think I can leverage field definitiion rules to do the same, can you provide a contrived example?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What page in the wiki are you referring to, @Paul Ward?
As for your further question - for your Jira ticket, do you need ALL the choices, even not selected ones?
I cannot link the 2 things together here - you are working with JavaScript to get some values, which is UI, and then you talk about Jira ticket creation from ConfiForms, which is clearly the "server side"
Do you know that the contents of your IFTTT macros is also processed as a Velocity template? Which means you can do the #if#else#end and looping in the IFTTT macro body?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I could not get #if#else#end working (was one of the first things I tried - hence went to try JS). I will give that another attempt and will post the storage format and result here tomorrow
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Not having much luck @Alex Medved _ConfiForms_. I used https://wiki.vertuna.com/display/CONFIFORMS/Conditional+statements+in+IFTTT+macro+body as a guide, then also https://community.atlassian.com/t5/Jira-questions/Conditions-in-Confiforms-IFTTT-Macro/qaq-p/790372 and https://wiki.apache.org/velocity/CheckingForNull and I found that none of the three approaches allowed me to check for "have any checkboxes in the group been selected" per the form below.
<p>
<ac:structured-macro ac:macro-id="d9c5fb18-65de-4234-99b7-70eeb96cb224" ac:name="confiform-entry-register" ac:schema-version="1">
<ac:parameter ac:name="formName">Form1</ac:parameter>
<ac:parameter ac:name="presetValues">sendto=[user.email]</ac:parameter>
<ac:parameter ac:name="registrationButtonLabel">Option 1</ac:parameter>
<ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter>
<ac:rich-text-body>
<p>
<ac:structured-macro ac:macro-id="01af663a-56b3-48a2-9f5c-10b21dbe8ff1" ac:name="confiform-field" ac:schema-version="1">
<ac:parameter ac:name="fieldName">F1</ac:parameter>
<ac:parameter ac:name="withLabel">true</ac:parameter>
</ac:structured-macro> <ac:structured-macro ac:macro-id="afa65fce-2c48-4793-ba35-024b84628ce7" ac:name="confiform-field" ac:schema-version="1">
<ac:parameter ac:name="fieldName">sendto</ac:parameter>
<ac:parameter ac:name="withLabel">true</ac:parameter>
</ac:structured-macro>
</p>
</ac:rich-text-body>
</ac:structured-macro>
</p>
<ac:structured-macro ac:macro-id="70725982-a720-4e67-a8d9-2548153ae8b1" ac:name="confiform" ac:schema-version="1">
<ac:parameter ac:name="formName">Form1</ac:parameter>
<ac:rich-text-body>
<p>
<ac:structured-macro ac:macro-id="c85c2b35-b56c-44ae-9eef-5a7b45ec8b00" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">F1</ac:parameter>
<ac:parameter ac:name="fieldLabel">choose wisely</ac:parameter>
<ac:parameter ac:name="values">false[1=One|2=Two|]</ac:parameter>
<ac:parameter ac:name="extras">on</ac:parameter>
<ac:parameter ac:name="type">checkbox_group</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="66131699-6a1a-4fcc-b84b-868f9da0b079" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">sendto</ac:parameter>
<ac:parameter ac:name="fieldLabel">Email</ac:parameter>
<ac:parameter ac:name="type">text</ac:parameter>
<ac:parameter ac:name="required">true</ac:parameter>
</ac:structured-macro>
</p>
<ac:structured-macro ac:macro-id="df3adfe0-0d8e-40f0-99c0-fb9a9639d64e" ac:name="confiform-ifttt" ac:schema-version="1">
<ac:parameter ac:name="action">Send Email</ac:parameter>
<ac:parameter ac:name="extras">[entry.sendto]</ac:parameter>
<ac:parameter ac:name="event">onCreated</ac:parameter>
<ac:parameter ac:name="title">test email</ac:parameter>
<ac:parameter ac:name="who">[entry.sendto]</ac:parameter>
<ac:rich-text-body>
<p>F1 contains "[entry.F1]"</p>
<p> </p>
<p>
<strong>1) Test setting local Velocity variable</strong>
</p>
<p>#set($test = "[entry.F1]")</p>
<p>#if($test)</p>
<p>this always renders even if NO options are set</p>
<div>#end</div>
<p>#if(!$test)<br/>this never renders<br/>#end</p>
<p>
<strong>2) test using square brace entry notation</strong>
</p>
<p>
<br/>#if( $'[entry.F1]' )</p>
<p>this never renders</p>
<p>#end</p>
<p>#if( !$'[entry.F1]' )</p>
<p>this always renders even if options ARE set</p>
<p>#end</p>
<p> </p>
<p>
<strong>3) test using curly brace notation</strong>
</p>
<p> </p>
<p>#if( ${F1} )</p>
<p>
<span>this always renders even if NO options are set</span>
</p>
<p>
<span> </span>#end</p>
<p>#if( !${F1} )</p>
<p>this never renders</p>
<div>#end</div>
<p> </p>
</ac:rich-text-body>
</ac:structured-macro>
</ac:rich-text-body>
</ac:structured-macro>
The end result I want is something like this in the Jira action macro body (simplified version):
#set($desc = "*Services Required*\n\n\nComments: [entry.Comments.escapeJSON]\n\n")
#if(${F1} $desc = $desc + "|Service options|[entry.F1.label|\n" #end
#if(${F2} $desc = $desc + "|Service options|[entry.F2.label|\n" #end
#if(${F3} $desc = $desc + "|Service options|[entry.F3.label|\n" #end
{
"fields":
{
"project": {
"key": "[entry.JiraProject.escapeJSON]"
},
"issuetype": {
"name": "[entry.JiraIssueType.escapeJSON]"
},
"summary": "[entry.ProjectName.escapeJSON]",
"description": $desc
}
}
That would only be MVP1. Ideally I would like to do this for the individual checkbox group item:
#if(${F1.One} $desc = $desc + "|Service option|some text|\n" #end
#if(${F1.Two} $desc = $desc + "|Service option|some text|\n" #end
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
OK, it looks like the template is evaluated in a bit incorrect order.
That is why it does not work like it should. There was a reason why we did it like this, and I am investigating this with the team
Sorry for the trouble
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.