Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

JIRA Plugin custom field multi select

CGM December 18, 2015

hi dear community,

I have write a custom field which get values from an external SQL database and read it in a multi selected custom field.

If I set a value to the custom field all is working fine, but there is a problem if I move the Issue to a another project the value is still exist in the new issue, although it doesn't have values in the other project. 

The database query select our available teams for a specific project.

 

 

public class FunctionalTeamCF extends GenericTextCFType

{

    private static Connection conn;

    private static Statement statement;

    

 

    protected FunctionalTeamCF(CustomFieldValuePersister customFieldValuePersister,

            GenericConfigManager genericConfigManager,

            TextFieldCharacterLengthValidator textFieldCharacterLengthValidator,

            JiraAuthenticationContext jiraAuthenticationContext) {

        super(customFieldValuePersister, genericConfigManager, textFieldCharacterLengthValidator, jiraAuthenticationContext);

    }

    

    @Override

    public Map getVelocityParameters(Issue issue, CustomField field, FieldLayoutItem fieldLayoutItem)

    {    

        Map map = new HashMap();

        Map<String, String> results = new HashMap<String, String>();    

 

        //aktuelles Issue Projekt

        String project = issue.getProjectObject().getKey();            

        results = getValues(project);;

        

        if(!results.isEmpty() && results != null)

        {

            map.put("results", results);

        }

        else

        {

            map.put("results", "None");

        }

        return map;

    }

 

I suspect that the velocity template file edit.vm makes the problems..

 

#* @vtlvariable name="results" type="java.util.Map" *#
#controlHeader ($action $customField.id $customField.name $fieldLayoutItem.required $displayParameters.noHeader)

    #if($value && !$value.equals(""))
    #set ($displayValue = ${value})
    #end    
    
    #if($results && !$results.equals("") && !$results.empty)
        <select class="text long-field" name="$customField.id" id="$customField.id" >
           <option value="">None</option>
           #foreach ($mapEntry in $results.entrySet())
                <option value="$mapEntry.key">$mapEntry.value</option>
           #end
        </select>  
    #else
        <select class="text long-field" name="$customField.id" id="$customField.id" >
            <option value="">None</option>
        </select>
        #set ($Value = "")
     #end

#controlFooter ($action $fieldLayoutItem.fieldDescription $displayParameters.noHeader)

2 answers

1 vote
Phill Fox
Community Champion
December 18, 2015

Hi 

Your code will read the value and store it in the JIRA database, however it will not refresh that value when you move the issue to another project. So you need to understand that once the value is stored it will not be updated as a "live value" until your code is executed again. 

Depending on how frequently you move issues it may be worthwhile having a "refresh values" step in your workflow for those times when you need to update that would execute your code and store the values pulled at that time. These would then use the parameters from the new project rather than the previous project.

Hope this helps

Phill

0 votes
CGM January 3, 2016

Is there a specific method in the JIRA SDK which I could use for an issue update in the JIRA database ?

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, confluence administration certification, atlassian certified professional, confluence admin for cloud, atlassian learning, confluence training, confluence certification exam, confluence cloud admin, admin credential, atlassian certification

Become a certified Confluence admin today! 📖

Stand out as a skilled Confluence Cloud administrator. The Confluence Administration for Cloud certification proves you can configure permissions, manage site and space settings, and monitor activity—ensuring secure, effective collaboration for your team.

Start here
AUG Leaders

Atlassian Community Events