if condition is not working as expected IFTTT macro

sai kumar January 4, 2024
if condition is not working as expected IFTTT macro.
Have two fields NodeVersion and FeatureName,  these are visible based on radio button option.
If  condition is not working as expected. If I entered the value i in FeatureName, still it is if block for node is executing.
 
my requirement is  field values to be populated at JIRA if either NodeVersion/ FeatureName  fields has value.
#set($title = "") 
#set($feature = "[entry.FeatureName]")
#set($node = "[entry.NodeVersion]")
#if(!${node})
#set($desc = "*Node Version:* [entry.NodeVersion]")
#set($title = "node version [entry.NodeVersion]")
  #elseif($feature)
    #set($desc = "*Feature Name:* [entry.FeatureName]")
  #set($title = "feature name [entry.FeatureName]")
#end
{     "fields":         {         "project": {"key": "ADMIN"},         "issuetype": {"name": "Request"},         "customfield_14362": [{"value": "TestAPP"}],         "labels": ["CA-TestApps"],         "summary": "Create ConsumerApp TestApps for the ${title}",         "description": "*GitBranch:* [entry.Branch]\n ${desc}" } }

tried with negation of isEmpty()
#if(!${NodeVersion.isEmpty()})
       #set($desc = "*Node Version:* [entry.NodeVersion]")
       #set($title = "node version [entry.NodeVersion]")
#elseif(!${FeatureName.isEmpty()})
      #set($desc = "*Feature Name:* [entry.FeatureName]")
      #set($title = "feature name [entry.FeatureName]")
#end

I am herewith giving the storage format, Can you please suggest where I am wrong.
<p class="auto-cursor-target">
<br/>
</p>
<p>
<br/>
</p>
<ac:structured-macro ac:macro-id="e6b5fa42-01af-4fc3-acfd-ae625b70f334" ac:name="group-checker" ac:schema-version="1">
  <ac:parameter ac:name="Group">jira-users</ac:parameter>
  <ac:parameter ac:name="DisplayWarning">true</ac:parameter>
  <ac:parameter ac:name="Message">You need to be logged in to Confluence before you can access this form.  Once you have logged in to Confluence, the request form will be available to you</ac:parameter>
  <ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter>
  <ac:rich-text-body>
    <p class="auto-cursor-target">
      <br/>
    </p>
    <ac:structured-macro ac:macro-id="8d69a641-d41e-461a-8766-714a758df5e3" ac:name="confiform" ac:schema-version="1">
      <ac:parameter ac:name="formName">TestApps</ac:parameter>
      <ac:parameter ac:name="saveButtonLabel">Submit</ac:parameter>
      <ac:parameter ac:name="registrationFormTitle">Create  Test Apps</ac:parameter>
      <ac:rich-text-body>
        <p>
          <ac:structured-macro ac:macro-id="3583df69-e766-47bc-815c-8d5308decd3f" ac:name="confiform-field-definition" ac:schema-version="1">
            <ac:parameter ac:name="fieldPlaceholder">Enter Branch Name</ac:parameter>
            <ac:parameter ac:name="fieldName">Branch</ac:parameter>
            <ac:parameter ac:name="fieldLabel">Branch Name</ac:parameter>
            <ac:parameter ac:name="fieldDescription">Git Branch Name</ac:parameter>
            <ac:parameter ac:name="type">text</ac:parameter>
            <ac:parameter ac:name="required">true</ac:parameter>
          </ac:structured-macro>
        </p>
        <p>
          <ac:structured-macro ac:macro-id="18cbfafb-a82c-44aa-bff4-9f5ba4dc7b3e" ac:name="confiform-field-definition" ac:schema-version="1">
            <ac:parameter ac:name="fieldName">NodeUpgrade</ac:parameter>
            <ac:parameter ac:name="fieldLabel">Node Upgrade</ac:parameter>
            <ac:parameter ac:name="values">true[0=Yes|1=No|]</ac:parameter>
            <ac:parameter ac:name="fieldDescription">Select Yes if you need to update Node Version</ac:parameter>
            <ac:parameter ac:name="type">radio_group</ac:parameter>
          </ac:structured-macro>
        </p>
        <p>
          <ac:structured-macro ac:macro-id="253f3f10-db3f-4a43-90bd-e0dd8873716c" ac:name="confiform-field-definition" ac:schema-version="1">
            <ac:parameter ac:name="fieldName">NodeVersion</ac:parameter>
            <ac:parameter ac:name="fieldLabel">Node Version</ac:parameter>
            <ac:parameter ac:name="type">text</ac:parameter>
          </ac:structured-macro>
        </p>
        <p>
          <ac:structured-macro ac:macro-id="f87bc343-8417-427a-870c-298b6fa8be9c" ac:name="confiform-field-definition" ac:schema-version="1">
            <ac:parameter ac:name="fieldName">FeatureName</ac:parameter>
            <ac:parameter ac:name="fieldLabel">Feature Name</ac:parameter>
            <ac:parameter ac:name="fieldDescription">App names will become BestBuy-Android-FeatureName and BestBuy-iOS-FeatureName</ac:parameter>
            <ac:parameter ac:name="type">text</ac:parameter>
          </ac:structured-macro>
        </p>
        <p>
          <ac:structured-macro ac:macro-id="6fca3642-3256-46e1-9c41-06f6c706377e" ac:name="confiform-field-definition-rules" ac:schema-version="1">
            <ac:parameter ac:name="condition">NodeUpgrade:[empty]</ac:parameter>
            <ac:parameter ac:name="fieldName">NodeVersion</ac:parameter>
            <ac:parameter ac:name="action">Hide field</ac:parameter>
            <ac:parameter ac:name="actionFieldName">NodeUpgrade</ac:parameter>
            <ac:parameter ac:name="withReverseRule">true</ac:parameter>
          </ac:structured-macro>
        </p>
        <p>
          <ac:structured-macro ac:macro-id="ddc508c1-dcb3-4a24-8c9c-1f74d3894376" ac:name="confiform-field-definition-rules" ac:schema-version="1">
            <ac:parameter ac:name="condition">NodeUpgrade:[empty]</ac:parameter>
            <ac:parameter ac:name="fieldName">FeatureName</ac:parameter>
            <ac:parameter ac:name="action">Hide field</ac:parameter>
            <ac:parameter ac:name="actionFieldName">NodeUpgrade</ac:parameter>
            <ac:parameter ac:name="withReverseRule">true</ac:parameter>
          </ac:structured-macro>
        </p>
        <p>
          <ac:structured-macro ac:macro-id="d559164e-5bf3-4869-ae4a-1e75c3fdb7f6" ac:name="confiform-field-definition-rules" ac:schema-version="1">
            <ac:parameter ac:name="condition">NodeUpgrade:0</ac:parameter>
            <ac:parameter ac:name="fieldName">FeatureName</ac:parameter>
            <ac:parameter ac:name="action">Hide field</ac:parameter>
            <ac:parameter ac:name="actionFieldName">NodeUpgrade</ac:parameter>
            <ac:parameter ac:name="withReverseRule">true</ac:parameter>
          </ac:structured-macro>
        </p>
        <p>
          <ac:structured-macro ac:macro-id="9a40e69f-1e66-4784-91c8-0aa405d4988c" ac:name="confiform-field-definition-rules" ac:schema-version="1">
            <ac:parameter ac:name="condition">NodeUpgrade:0</ac:parameter>
            <ac:parameter ac:name="fieldName">NodeVersion</ac:parameter>
            <ac:parameter ac:name="action">Show field</ac:parameter>
            <ac:parameter ac:name="actionFieldName">NodeUpgrade</ac:parameter>
            <ac:parameter ac:name="withReverseRule">true</ac:parameter>
          </ac:structured-macro>
        </p>
        <p>
          <ac:structured-macro ac:macro-id="722ff894-dc8a-4417-be2b-2fc51e4d8afe" ac:name="confiform-field-definition-rules" ac:schema-version="1">
            <ac:parameter ac:name="condition">NodeUpgrade:0</ac:parameter>
            <ac:parameter ac:name="fieldName">FeatureName</ac:parameter>
            <ac:parameter ac:name="action">Reset value</ac:parameter>
            <ac:parameter ac:name="actionFieldName">NodeUpgrade</ac:parameter>
            <ac:parameter ac:name="withReverseRule">true</ac:parameter>
          </ac:structured-macro>
        </p>
        <p>
          <ac:structured-macro ac:macro-id="538d6497-7dee-4496-a59b-79404da6cdca" ac:name="confiform-field-definition-rules" ac:schema-version="1">
            <ac:parameter ac:name="condition">NodeUpgrade:1</ac:parameter>
            <ac:parameter ac:name="fieldName">Feature Name</ac:parameter>
            <ac:parameter ac:name="action">Show field</ac:parameter>
            <ac:parameter ac:name="actionFieldName">NodeUpgrade</ac:parameter>
            <ac:parameter ac:name="withReverseRule">true</ac:parameter>
          </ac:structured-macro>
        </p>
        <p>
          <ac:structured-macro ac:macro-id="1038df77-6b0d-422c-ad0c-b36df93d1e1d" ac:name="confiform-field-definition-rules" ac:schema-version="1">
            <ac:parameter ac:name="condition">NodeUpgrade:1</ac:parameter>
            <ac:parameter ac:name="fieldName">Node Version</ac:parameter>
            <ac:parameter ac:name="action">Reset value</ac:parameter>
            <ac:parameter ac:name="actionFieldName">NodeUpgrade</ac:parameter>
            <ac:parameter ac:name="withReverseRule">true</ac:parameter>
          </ac:structured-macro>
        </p>
        <p>
          <ac:structured-macro ac:macro-id="6a62c5e1-5347-42ef-8009-13a9385fcf05" ac:name="confiform-field-definition" ac:schema-version="1">
            <ac:parameter ac:name="fieldName">s</ac:parameter>
            <ac:parameter ac:name="fieldLabel">Save</ac:parameter>
            <ac:parameter ac:name="values">Save Details</ac:parameter>
            <ac:parameter ac:name="type">checkbox</ac:parameter>
            <ac:parameter ac:name="required">true</ac:parameter>
          </ac:structured-macro>
        </p>
        <p>
          <ac:structured-macro ac:macro-id="66bca663-d53e-41fa-90d5-5a3e522ba395" ac:name="confiform-field-definition-rules" ac:schema-version="1">
            <ac:parameter ac:name="condition">s:true</ac:parameter>
            <ac:parameter ac:name="values">showValueFunc5(formName, formId);</ac:parameter>
            <ac:parameter ac:name="action">Run custom JavaScript</ac:parameter>
            <ac:parameter ac:name="actionFieldName">s</ac:parameter>
          </ac:structured-macro>
        </p>
        <p>
          <ac:structured-macro ac:macro-id="af1e34f7-af7a-4394-9e47-a97531b27e8d" ac:name="confiform-field-definition" ac:schema-version="1">
            <ac:parameter ac:name="fieldName">confirm</ac:parameter>
            <ac:parameter ac:name="fieldLabel">Confirm</ac:parameter>
            <ac:parameter ac:name="type">checkbox</ac:parameter>
            <ac:parameter ac:name="required">true</ac:parameter>
          </ac:structured-macro>
        </p>
        <p>
          <ac:structured-macro ac:macro-id="8abd383e-efd4-4cd4-a2e6-ae6edbf64ac8" ac:name="confiform-field-definition-rules" ac:schema-version="1">
            <ac:parameter ac:name="condition">confirm:false</ac:parameter>
            <ac:parameter ac:name="values">hideSaveButton();</ac:parameter>
            <ac:parameter ac:name="action">Run custom JavaScript</ac:parameter>
            <ac:parameter ac:name="actionFieldName">confirm</ac:parameter>
          </ac:structured-macro>
        </p>
        <p>
          <ac:structured-macro ac:macro-id="dc5f8162-e76e-4b70-af81-ae28d17732cb" ac:name="confiform-field-definition-rules" ac:schema-version="1">
            <ac:parameter ac:name="condition">confirm:false</ac:parameter>
            <ac:parameter ac:name="fieldName">confirm</ac:parameter>
            <ac:parameter ac:name="action">Hide field</ac:parameter>
            <ac:parameter ac:name="actionFieldName">confirm</ac:parameter>
          </ac:structured-macro>
        </p>
        <p>Create Test Apps in AppCenter</p>
        <ac:structured-macro ac:macro-id="5581d00c-b2c2-40f9-acd6-fd2fb794688b" ac:name="confiform-entry-register" ac:schema-version="1">
          <ac:parameter ac:name="overrideSaveButtonLabel">Submit</ac:parameter>
          <ac:parameter ac:name="formName">TestApps</ac:parameter>
          <ac:parameter ac:name="registrationButtonLabel">Create Test Apps</ac:parameter>
          <ac:parameter ac:name="autoAlign">true</ac:parameter>
          <ac:parameter ac:name="autofocus">true</ac:parameter>
          <ac:parameter ac:name="regControlLayout">true</ac:parameter>
          <ac:rich-text-body>
            <p>
              <br/>
            </p>
            <p class="auto-cursor-target">
              <span style="color: rgb(51,102,255);">Select Save and click OK on popup window to see the submit option.</span>
            </p>
          </ac:rich-text-body>
        </ac:structured-macro>
        <p class="auto-cursor-target">
          <br/>
        </p>
        <ac:structured-macro ac:macro-id="d079499b-a19c-49c6-971d-e005ffb7aef2" ac:name="confiform-ifttt" ac:schema-version="1">
          <ac:parameter ac:name="action">Create JIRA Issue</ac:parameter>
          <ac:parameter ac:name="event">onCreated</ac:parameter>
          <ac:rich-text-body>
            <p class="auto-cursor-target">
              <br/>
            </p>
            <ac:structured-macro ac:macro-id="74c8e2d0-445f-418a-9ee7-9fec91a9de80" ac:name="noformat" ac:schema-version="1">
              <ac:plain-text-body><![CDATA[#set($desc ="")
#set($title = "") 
#set($feature = "[entry.FeatureName]")
#set($node = "[entry.NodeVersion]")
#if(!${node})
#set($desc = "*Node Version:* [entry.NodeVersion]")
#set($title = "node version [entry.NodeVersion]")
  #elseif($feature)
    #set($desc = "*Feature Name:* [entry.FeatureName]")
  #set($title = "feature name [entry.FeatureName]")
#end
 
{
    "fields":
        {
        "project": {"key": "ADMIN"},
        "issuetype": {"name": "Request"},
        "customfield_14362": [{"value": "Test-App"}],
        "labels": ["CA-TestApps"],
        "summary": "Create TestApps for the ${title}",
        "description": "*GitBranch:* [entry.Branch]\n ${desc}"
}
}]]></ac:plain-text-body>
            </ac:structured-macro>
            <p>
              <br/>
            </p>
            <p class="auto-cursor-target">
              <br/>
            </p>
          </ac:rich-text-body>
        </ac:structured-macro>
        <p class="auto-cursor-target">
          <br/>
        </p>
      </ac:rich-text-body>
    </ac:structured-macro>
    <p class="auto-cursor-target">
      <br/>
    </p>
  </ac:rich-text-body>
</ac:structured-macro>
<p class="auto-cursor-target">
  <br/>
</p>

1 answer

0 votes
Alex Medved _ConfiForms_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 4, 2024

Hi @sai kumar 

The following check will always be true

#if(!${node})

as one line above in the code you set it's value. Check this helper page we have put on for clarifying and summarising Velocity templating tricks https://wiki.vertuna.com/display/CONFIFORMS/IFTTT+macro+body+evaluates+as+Velocity+template or check Apache Velocity documentation on how to use IF and conditions for empty/null, etc

Alex 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events