updateValue for Custom Field in Jelly Script

Mia
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 8, 2013

I'm doing my head in trying to get the updateValue method to work. However, all my attempts at getting down to this method from OrderableField are failing.

Does anyone know how to access the updateValue() method in jelly so it will update the value of a custom field? Thanks!

At present this is the error I am receiving:
Error: <JiraJelly xmlns:jira="jelly:com.atlassian.jira.jelly.enterprise.JiraTagLib" xmlns:core="jelly:core" xmlns:log="jelly:log">
Exception: org.apache.commons.jelly.JellyTagException: null:14:0: No such accessible method: getOrderableField() on object: com.atlassian.jira.issue.fields.DefaultFieldManager java.io.PrintWriter@4717dd62

This is the code at present:

&lt;JiraJelly xmlns:jira="jelly:com.atlassian.jira.jelly.enterprise.JiraTagLib" xmlns:core="jelly:core" xmlns:log="jelly:log" &gt;
	&lt;jira:Login username="[username]" password="[password]"&gt;
		&lt;log:info&gt;Running Priority Escalation Service&lt;/log:info&gt;
		&lt;!-- Get an instance of ComponentManager --&gt;
		&lt;core:invokeStatic className="com.atlassian.jira.ComponentManager" method="getInstance" var="componentManager"/&gt;
		&lt;!-- Get custom field manager --&gt;
		&lt;core:invokeStatic className="com.atlassian.jira.component.ComponentAccessor" method="getCustomFieldManager" var="customFieldManager"/&gt;
		&lt;!-- Get field manager --&gt;
		&lt;core:invokeStatic className="com.atlassian.jira.component.ComponentAccessor" method="getFieldAccessor" var="fieldManager"/&gt;
		&lt;!-- Get IssueManager from ComponentManager --&gt;
		&lt;core:invoke on="${componentManager}" method="getIssueManager" var="issueManager"/&gt;
		
		&lt;core:invoke on="${componentManager}" method="getIssueUpdater" var="issueUpdater"/&gt;
		&lt;core:invoke on="${fieldManager}" method="getOrderableField" var="orderField"/&gt;
		
		&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="Urgency"/&gt;
		&lt;/core:invoke&gt;
				
		&lt;!-- Properties for the script --&gt;
		&lt;core:set var="comment"&gt;The priority of the issue has been escalated due to the approaching due date.&lt;/core:set&gt;
		&lt;core:set var="filter5to24" value="13400" /&gt;
		&lt;core:set var="issueBean" value="${issueKey},${issueKey},IssueEventType.ISSUE_UPDATED,${username}" /&gt;
		
		&lt;!-- Run the SearchRequestFilter --&gt;
		&lt;jira:RunSearchRequest filterid="${filter5to24}" var="issues" /&gt;\
		
		&lt;!-- Iterate over the issues --&gt;
		&lt;core:forEach var="issue" items="${issues}"&gt;
			&lt;log:warn&gt;Updating urgency and priority on issue ${issue.key}&lt;/log:warn&gt;
			
			&lt;!-- Get the Issue from IssueManager --&gt;
			&lt;core:invoke on="${issueManager}" method="getIssueObject" var="issueKey"&gt;
				&lt;core:arg type="java.lang.String" value="${issue.key}"/&gt;
			&lt;/core:invoke&gt;
			 
			&lt;!-- Get Custom Field Value --&gt;
			&lt;core:invoke on="${myField}" method="getValue" var="myFieldValue"&gt;
				&lt;core:arg type="com.atlassian.jira.issue.IssueImpl" value="${issueKey}"/&gt;
			&lt;/core:invoke&gt;
			
			&lt;!-- update urgency --&gt;
			&lt;core:invoke on="${myField}" method="updateValue" var="updFieldValue"&gt;
				&lt;core:arg type="java.lang.String" value="10804"/&gt;
			&lt;/core:invoke&gt;
			
			&lt;!-- save issue and fire an event --&gt;
			&lt;core:invoke on="${issueUpdater}" method="doUpdate" var="updatePri"&gt;
				&lt;core:arg type="java.lang.String" value="${issueBean}, true"/&gt;
			&lt;/core:invoke&gt;
			
			&lt;!-- add comment --&gt;
			&lt;jira:AddComment issue-key="${issue.key}" comment="${comment}"/&gt;
		&lt;/core:forEach&gt;
	
	&lt;/jira:Login&gt;
&lt;/JiraJelly&gt;

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
Mia
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 12, 2013

Nevermind. I went back to using the bulti-in script Escalation Service and finally got that to work as I needed.

Goran Rasic September 11, 2013

can you share the solution with us.. I am struggeling with same issue.. need to update a custom filed using Jelly..

Thanks!!

0 votes
Sri N October 23, 2013

Can you please post the solution. I tried with the example one on atlassian website and it doesn't work. All I see is

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

file:/local/jira/releasepath/home/jelly/approve_rmc_packets.jelly:33:95: <core:new> com.atlassian.jira.issue.fields.DefaultFieldManager” in the log file nothing else. And my script is based on the one they had in examples (https://developer.atlassian.com/display/JIRADEV/Jelly+Examples?focusedCommentId=184549408) to update custom field

TAGS
AUG Leaders

Atlassian Community Events