Update Custom Field Value works, however the Filter does not see the new value

I have created a Jelly Sript to update a custom file (Group Picker)..

the sript works fine however the filter used to identify the issues which should be updated does not "see" the new values .. it still has the old values even the field is updated..

here my test script (Sorry for the debug and commented areas)

<JiraJelly xmlns:jira="jelly:com.atlassian.jira.jelly.enterprise.JiraTagLib" xmlns:core="jelly:core" xmlns:log="jelly:log" >

<jira:Login username="user" password="pwd">

<log:info>Reset Support Group</log:info>

<!-- Set the SearchRequestFilter for all Teams -->

<core:set var="filterWebTeam" value="11000" />

<core:set var="filterEMEATeam" value="11001" />

<core:set var="filterNATeam" value="11002" />

<core:set var="filterOpsTeam" value="11003" />

<core:set var="filterQADTeam" value="11004" />

<core:set var="filterAPTeam" value="11005" />

<core:new var="changeHolder" className="com.atlassian.jira.issue.util.DefaultIssueChangeHolder"/>

<!-- Get an instance of ComponentManager -->

<core:invokeStatic className="com.atlassian.jira.ComponentManager" method="getInstance" var="componentManager"/>

<!-- Get Custom FieldManager from ComponentManager -->

<core:invoke on="${componentManager}" method="getCustomFieldManager" var="customFieldManager" />

<!-- Get the IssueManager from ComponentManager -->

<core:invoke on="${componentManager}" method="getIssueManager" var="issueManager" />

<!-- FIRST RUN THROUGH THE WEB TEAM FILTER -->

<jira:RunSearchRequest filterid="${filterWebTeam}" var="issues" />

<core:forEach var="issue" items="${issues}">

<!-- Grab an instance of ComponentManager -->

<core:invokeStatic className="com.atlassian.jira.ComponentManager" method="getInstance" var="componentManager"/>

<core:invokeStatic className="com.atlassian.jira.component.ComponentAccessor" method="getIssueService" var="issueService"/>

<!-- Get CustomField object from customFieldManager -->

<core:invoke on="${customFieldManager}" method="getCustomFieldObjectByName" var="customFieldObj">

<core:arg type="java.lang.String" value="Support Group"/>

</core:invoke>

<core:invoke on="${componentManager}" method="getIssueUpdater" var="issueUpdater"/>

<!-- Get the Issue from IssueManager current to be changed Issues -->

<core:invoke on="${issueManager}" method="getIssueObject" var="issueKey">

<core:arg type="java.lang.String" value="${issue.key}"/>

</core:invoke>

<!-- Get the Issue from IssueManager default Issue for Web team -->

<core:invoke on="${issueManager}" method="getIssueObject" var="issueKey2">

<core:arg type="java.lang.String" value="TEST-171"/>

</core:invoke>

<!-- Get Custom Field Value -->

<core:invoke on="${customFieldObj}" method="getValue" var="myFieldValue">

<core:arg type="com.atlassian.jira.issue.IssueImpl" value="${issueKey}"/>

</core:invoke>

<core:set var="issueBean" value="${issueKey},${issueKey},IssueEventType.ISSUE_UPDATED,${username}" />

<!-- Get Custom Field Value SLA AP ERP -->

<core:invoke on="${customFieldObj}" method="getValue" var="myFieldValueNew">

<core:arg type="com.atlassian.jira.issue.IssueImpl" value="${issueKey2}"/>

</core:invoke>

<log:warn>OLD VALUE [${myFieldValue}] - NEW VALUE[${myFieldValueNew}]</log:warn>

<core:new var="modifiedValue" className="com.atlassian.jira.issue.ModifiedValue">

<core:arg type="java.lang.Object" value="${myFieldValue}" />

<core:arg type="java.lang.Object" value="${myFieldValueNew}" />

</core:new>

<core:invoke on="${customFieldObj}" method="updateValue" var="assignedgroup">

<core:arg type="com.atlassian.jira.issue.fields.layout.field.FieldLayoutItemImpl" value="${null}"/>

<core:arg type="com.atlassian.jira.issue.IssueImpl" value="${issueKey}"/>

<core:arg type="com.atlassian.jira.issue.ModifiedValue" value="${modifiedValue}"/>

<core:arg type="com.atlassian.jira.issue.util.DefaultIssueChangeHolder" value="${changeHolder}"/>

</core:invoke>

<!-- save issue -->

<!--

<core:invoke on="${issueUpdater}" method="doUpdate" var="updatePri">

<core:arg type="java.lang.String" value="${issueBean}, true"/>

</core:invoke>

-->

<core:getStatic

className="com.atlassian.jira.event.type.EventDispatchOption"

field="ISSUE_UPDATED"

var="dispatchOption" />

<core:invoke on="${issueKey}" method="store" />

<core:invoke on="${issueManager}" method="updateIssue">

<core:arg type="com.atlassian.crowd.embedded.api.User" value="${jira.user}" />

<core:arg type="com.atlassian.jira.issue.MutableIssue" value="${issueKey}" />

<core:arg type="com.atlassian.jira.event.type.EventDispatchOption" value="${dispatchOption}" />

<core:arg type="boolean" value="false" />

</core:invoke>

<core:invoke on="${issueKey}" method="store" />

</core:forEach>

<!-- Second QAD Team -->

<jira:RunSearchRequest filterid="${filterQADTeam}" var="issues" />

<core:forEach var="issue" items="${issues}">

<!-- Grab an instance of ComponentManager -->

<core:invokeStatic className="com.atlassian.jira.ComponentManager" method="getInstance" var="componentManager"/>

<core:invokeStatic className="com.atlassian.jira.component.ComponentAccessor" method="getIssueService" var="issueService"/>

<!-- Get CustomField object from customFieldManager -->

<core:invoke on="${customFieldManager}" method="getCustomFieldObjectByName" var="customFieldObj">

<core:arg type="java.lang.String" value="Support Group"/>

</core:invoke>

<core:invoke on="${componentManager}" method="getIssueUpdater" var="issueUpdater"/>

<!-- Get the Issue from IssueManager current to be changed Issues -->

<core:invoke on="${issueManager}" method="getIssueObject" var="issueKey">

<core:arg type="java.lang.String" value="${issue.key}"/>

</core:invoke>

<!-- Get the Issue from IssueManager default Issue for QADteam -->

<core:invoke on="${issueManager}" method="getIssueObject" var="issueKey2">

<core:arg type="java.lang.String" value="TEST-176"/>

</core:invoke>

<!-- Get Custom Field Value -->

<core:invoke on="${customFieldObj}" method="getValue" var="myFieldValue">

<core:arg type="com.atlassian.jira.issue.IssueImpl" value="${issueKey}"/>

</core:invoke>

<!-- Get Custom Field Value SLA AP ERP -->

<core:invoke on="${customFieldObj}" method="getValue" var="myFieldValueNew">

<core:arg type="com.atlassian.jira.issue.IssueImpl" value="${issueKey2}"/>

</core:invoke>

<core:set var="issueBean" value="${issueKey},${issueKey},IssueEventType.ISSUE_UPDATED,${username}" />

<log:warn>OLD VALUE [${myFieldValue}] - NEW VALUE[${myFieldValueNew}]</log:warn>

<core:new var="modifiedValue" className="com.atlassian.jira.issue.ModifiedValue">

<core:arg type="java.lang.Object" value="${myFieldValue}" />

<core:arg type="java.lang.Object" value="${myFieldValueNew}" />

</core:new>

<core:invoke on="${customFieldObj}" method="updateValue" var="assignedgroup">

<core:arg type="com.atlassian.jira.issue.fields.layout.field.FieldLayoutItemImpl" value="${null}"/>

<core:arg type="com.atlassian.jira.issue.IssueImpl" value="${issueKey}"/>

<core:arg type="com.atlassian.jira.issue.ModifiedValue" value="${modifiedValue}"/>

<core:arg type="com.atlassian.jira.issue.util.DefaultIssueChangeHolder" value="${changeHolder}"/>

</core:invoke>

<!-- save issue -->

<!-- save issue and fire an event -->

<!--

<core:invoke on="${issueUpdater}" method="doUpdate" var="updatePri">

<core:arg type="java.lang.String" value="${issueBean}, true"/>

</core:invoke>

<core:invoke on="${issueKey}" method="store" />

-->

<core:getStatic

className="com.atlassian.jira.event.type.EventDispatchOption"

field="ISSUE_UPDATED"

var="dispatchOption" />

<core:invoke on="${issueKey}" method="store" />

<core:invoke on="${issueManager}" method="updateIssue">

<core:arg type="com.atlassian.crowd.embedded.api.User" value="${jira.user}" />

<core:arg type="com.atlassian.jira.issue.MutableIssue" value="${issueKey}" />

<core:arg type="com.atlassian.jira.event.type.EventDispatchOption" value="${dispatchOption}" />

<core:arg type="boolean" value="true" />

</core:invoke>

<core:invoke on="${issueKey}" method="store" />

<!--

<core:invoke on="${issueService}" method="update" var="updateValidationResult">

<core:arg value="${jira.user}"/>

<core:arg value="${issueKey}"/>

<core:arg type="com.atlassian.jira.event.type.EventDispatchOption" value="${dispatchOption}" />

<core:arg type="boolean" value="false" />

</core:invoke>

-->

</core:forEach>

</jira:Login>

</JiraJelly>

2 answers

1 accepted

you have to do the reindex after updating issue, i am not sure how to do it using Jelly Script

Thanks I have added.. see below.. it actually works

however this means that everytime I ran this I have to reindex.. isnt there an easer way

<core:invokeon="${componentManager}"method="getIndexManager" var="indexManager" />

<core:invokeon="${indexManager}"method="reIndexAll"var="millis" />

Glad to hear it worked!!

when you update issue you have to reindex that issue, i think this is the easyest way insted of reindex entaire instance

Thanks !!

here the code to only reindex current updated issue

<core:invoke on="${componentManager}" method="getIndexManager" var="indexManager" />
<core:invoke on="${indexManager}" method="reIndex" var="millis" >
<core:arg type="com.atlassian.jira.issue.MutableIssue" value="${issueKey}" />
</core:invoke>

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,293 views 14 20
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
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