how do i update and index a MutableIssue in Jelly


I have done the following script to set the component of an issue, which works because i check components at the end of the script and its right, however the script does not seem to persist or store the changed values of my MutableIssue, see below:

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

<jira:Login username="user.survey" password="$uRv3y">

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

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

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

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

<core:arg type="java.lang.String" value="SUP-27096"/>


<core:invoke on="${componentManager}" method="getProjectComponentManager" var="projectComponentManager"/>

<core:invoke on="${projectComponentManager}" method="findByComponentName" var="projectComponent" >

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

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


<core:invoke on="${projectComponentManager}" method="convertToGenericValue" var="projectComponentGeneric" >

<core:arg type="com.atlassian.jira.bc.project.component.ProjectComponent" value="${projectComponent}"/>


<core:invoke on="${issueKey}" method="getComponents" var="components" />

<core:invoke on="${components}" method="add" var="flag">

<core:arg type="org.ofbiz.core.entity.GenericValue" value="${projectComponentGeneric}" />


<jira:AddComment comment="components ${components}" issue-key="SUP-27096"/>

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

<core:arg type="java.util.Collection" value="${components}" />




How do i persist this change?

Thanks in advance

2 answers

1 accepted

2 votes
Accepted answer

Try this, Justin. I've run it on my development machine, and it did update the component of my sample issue.

&lt;?xml version="1.0" encoding="utf-8" standalone="yes"?&gt;
&lt;JiraJelly xmlns:jira="jelly:com.atlassian.jira.jelly.JiraTagLib" xmlns:core="jelly:core" xmlns:log="jelly:log"&gt;

&lt;jira:LoadManager var="issueManager" manager="IssueManager"/&gt;
&lt;jira:LoadManager var="projectManager" manager="ProjectManager"/&gt;

&lt;core:invoke on="${issueManager}" method="getIssueObject" var="issue"&gt;
	&lt;core:arg type="java.lang.String" value="ABC-1"/&gt;

&lt;core:invoke on="${projectManager}" method="getComponent" var="projectComponent"&gt;
	&lt;core:arg type="java.lang.Long" value="10000"/&gt;

&lt;core:invoke on="${issue}" method="getComponents" var="components" /&gt;

&lt;core:invoke on="${components}" method="add"&gt;
	&lt;core:arg type="org.ofbiz.core.entity.GenericValue" value="${projectComponent}" /&gt;

&lt;core:invoke on="${issue}" method="setComponents"&gt;
	&lt;core:arg type="java.util.Collection" value="${components}" /&gt;

&lt;core:invoke on="${issue}" method="store" /&gt;

	var="dispatchOption" /&gt;

&lt;core:invoke on="${issueManager}" method="updateIssue"&gt;
	&lt;core:arg type="com.atlassian.crowd.embedded.api.User" value="${jira.user}" /&gt;
	&lt;core:arg type="com.atlassian.jira.issue.MutableIssue" value="${issue}" /&gt;
	&lt;core:arg type="com.atlassian.jira.event.type.EventDispatchOption" value="${dispatchOption}" /&gt;
	&lt;core:arg type="boolean" value="false" /&gt;

Note that I've used the component id as an argument to ProjectManager.getComponent. You can find the id of a component by clicking on the component and looking at the URL; for example: the URL for the OPS component that I defined was http://localhost:2990/jira/browse/ABC/component/10000, so the component id is 10000.

I didn't do the login thing, but you should be able to add that in just fine.

You need to call the store() method on the MutableIssue (MutableIssue inherits the store method from OfBizValueWrapper).

Note that, as of JIRA 5.0, the store() method is deprecated. The alternative is to use the IssueManager's updateIssue(...) method.

Awesome thanks David, I did try the store method however it didnt work:

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

and the updateissue expects a parameter which i am not sure how to get access to: com.atlassian.crowd.embedded.api.User user

Sorry I figured out the User but now I cant seem to figure out the EventDispatchOption eventDispatchOption

Ok I figured out how to get the user, but my problem now is specifing the primitive boolean arg, it needs the primitive and not java.lang.Boolean?

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

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

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

<core:arg type="java.lang.Boolean" value="false"/>


The only way i can think of doing it is :

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

but this wont work, keeps giving a null value.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published yesterday in Agile

How Scrum works? It starts with training and education

To answer “How scrum works,” most of the teams I've worked with first addressed the question: “where to start?”  That question applies to both implementation and improvements on the Scrum framew...

168 views 3 5
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