Velocity file

I have a select list and the default value is "Please Select a value from the list" . When the user has choosen default value. I want to display as Not Applicable instead of Please Select a value from the list.

How do we write condition display in edit.vm velocity file. I tried few options but it is not working. How do we write condition display in Jira velocity file?

4 answers

0 votes

You need to tell us what you've tried really.

Personally, I'd take a different approach and edit the actual text that's coming through - https://developer.atlassian.com/display/JIRADEV/Customizing+Text

Hello @Nic Brough [Adaptavist] I'm trying to use Jira editor in my plugin. But doesn't render properly and don't show the toolbar above the edit area. Can you help me?

Trial 2
----------

#customControlHeader ($action $customField.id $customField.name $fieldLayoutItem.required $displayParameters $auiparams)
<select class="select" name="$customField.id" id="$customField.id" style="width:auto">   
     #foreach ($option in $configs.options)     
        #if(!$option.disabled || $option.disabled == false || ($value && $value == $option.optionId.toString()))
          #if ($value && $value.equals($option.optionId.toString())) #set ($selected = ' selected="selected"') #else #set ($selected = '') #end
            #if ( $selected == $option.optionId.toString() )              
              <option selected="selected" value="$textutils.htmlEncode($!value)">
                   #if($textutils.htmlEncode($!value) = "Please a value from the list")
                         #set($value ="Not Applicable")
                    #end</option>
               #end
            #else                
                <option value=$option.optionId.toString()>$option.toString()</option>
            #end               
          #end
        #end    
</select>   
#customControlFooter ($action $customField.id $fieldLayoutItem.fieldDescription $displayParameters $auiparams)

The options i tried are

Trial 1
----------
#customControlHeader ($action $customField.id $customField.name $fieldLayoutItem.required $displayParameters $auiparams)
#if($value = "Please a value from the list")
  #set($value ="Not Applicable")
#end
<select class="select" name="$customField.id" id="$customField.id" style="width:auto">   
     #foreach ($option in $configs.options)     
        #if(!$option.disabled || $option.disabled == false || ($value && $value == $option.optionId.toString()))
          #if ($value && $value.equals($option.optionId.toString())) #set ($selected = ' selected="selected"') #else #set ($selected = '') #end
            #if ( $selected == $option.optionId.toString() )              
              <option selected="selected" value="$textutils.htmlEncode($!value)">$textutils.htmlEncode($!value) </option>
               #end
            #else                
                <option value=$option.optionId.toString()>$option.toString()</option>
            #end               
          #end
        #end    
</select>   
#customControlFooter ($action $customField.id $fieldLayoutItem.fieldDescription $displayParameters $auiparams)
Trial 3
----------

#customControlHeader ($action $customField.id $customField.name $fieldLayoutItem.required $displayParameters $auiparams)
<select class="select" name="$customField.id" id="$customField.id" style="width:auto">   
     #foreach ($option in $configs.options)     
        #if(!$option.disabled || $option.disabled == false || ($value && $value == $option.optionId.toString()))
          #if ($value && $value.equals($option.optionId.toString())) #set ($selected = ' selected="selected"') #else #set ($selected = '') #end
            #if ( $selected == $option.optionId.toString() )              
              <option selected="selected"  #if($value="Please a value from the list") #set($value ="Not Applicable")
                    #end>$textutils.htmlEncode($!value)</option>
               #end
            #else                
                <option value=$option.optionId.toString()>$option.toString()</option>
            #end               
          #end
        #end    
</select>   
#customControlFooter ($action $customField.id $fieldLayoutItem.fieldDescription $displayParameters $auiparams)

Suggest an answer

Log in or Join to answer
Community showcase
Bridget Sauer
Published Feb 08, 2018 in Agile

Community Showcase: Getting to know Kemal, AUG Leader from Bosnia and Herzegovina

  Cheers to Kemal Bajramovic, our first ever AUG Leader to be Showcased. AUG Leaders are passionate experts who find time in their own busy lives to host Atlassian themed events to share ...

202 views 3 4
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot