Transition issues when inactive in a specific state with custom field

I'm trying to create a simple Jelly Runner script to close issues in a certain project that have not been updated in two weeks. During the transition, a screen is defined with a required custom field.

This is what I got now:

<JiraJelly xmlns:jira="jelly:com.atlassian.jira.jelly.enterprise.JiraTagLib" xmlns:core="jelly:core" xmlns:log="jelly:log" >
<jira:Login username="rdem" password="XXXXXX">
        <log:warn>Running Inactive issues service</log:warn>
        <core:set var="comment">This issue is marked as Done, but has not been closed for two weeks.
  
An automated service will now close the ticket, and set the feedback to "Neutral".
  
Thank you,
  
  The IBQ team</core:set>
        <core:set var="workflowStep" value="Close" />
        <core:set var="workflowUser" value="rdem" />
  
        <!-- Run the SearchRequestFilter -->
        <jira:RunSearchRequest filterid="12345" var="issues" />
  
        <core:forEach var="issue" items="${issues}">
                <log:warn>Inactivating issue ${issue.key}</log:warn>
                <jira:TransitionWorkflow key="${issue.key}" user="${workflowUser}" workflowAction="${workflowStep}" comment="${comment}"/>
        </core:forEach>
</jira:Login>
</JiraJelly>

But this won't work, because during this transition, a certain custom field is required and I've no idea how to specify the default value for this field.

Any help please?

2 answers

1. You need to add this line before <core:set...> (line 10):

&lt;!-- Get CustomField object from customFieldManager --&gt;
        &lt;core:invoke on="${customFieldManager}" method="getCustomFieldObjectByName" var="myField"&gt;
            &lt;core:arg type="java.lang.String" value="Your custom field name"/&gt;
        &lt;/core:invoke&gt;

2. Then, add this line to update the value with whatever value you want after &lt;/log:warn&gt;
&lt;!-- update your custom field value - XXXXX--&gt;
            &lt;core:invoke on="${myField}" method="updateValue" var="updFieldValue"&gt;
                &lt;core:arg type="java.lang.String" value="[customfieldvalue - XXXXX]"/&gt;
            &lt;/core:invoke&gt;





Thanks for the reply. I'm trying but it's not working. I assume the approach is a little different if the custom field are a bunch of radio buttons?

Also, so I have to enter the name of the custom field or something more internal? (id)

Custom field name should work, not the id. Id needs to be used for the value of the custom field.

And for the radio button, check here:

https://answers.atlassian.com/questions/118367/assign-an-issue-based-on-radio-button-selection-groovy

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Sep 18, 2018 in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

24,950 views 2 7
Join discussion

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