how do i update and index a MutableIssue in Jelly

Hi

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>

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

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

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

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

</core:invoke>

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

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

</core:invoke>

<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}" />

</core:invoke>

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

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

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

</core:invoke>

</jira:Login>

</JiraJelly>

How do i persist this change?

Thanks in advance

2 answers

1 accepted

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&gt;

&lt;core:invoke on="${projectManager}" method="getComponent" var="projectComponent"&gt;
	&lt;core:arg type="java.lang.Long" value="10000"/&gt;
&lt;/core:invoke&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&gt;

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

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

&lt;core:getStatic 
	className="com.atlassian.jira.event.type.EventDispatchOption" 
	field="DO_NOT_DISPATCH"
	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;
&lt;/core:invoke&gt;
&lt;/JiraJelly&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"/>

</core:invoke>

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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published yesterday in Marketplace Apps

Tips on how to choose the best estimation method for your planning

Planning and grooming sessions all come with their own sets of rules. Team members meet to estimate stories or other work items, all according to an agreed-upon process. And with every session comes ...

57 views 0 11
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