Our new Appfire Documentation Space is now live!
Take a look here! If you have any questions please email support@appfire.com
setFieldValue(String <field_name>or<field_Id>, Object value)
setFieldValue(String <field_name>or<field_Id>, Object value)
method sets the value of a system or custom field of the Issue object where,
<field_name
> is the name of the field as displayed in the Field configuration<field_id>
is the ID of the field as shown in Accessing the Jira Standard fields of an issue document. In the case of a custom field, it has the formcustomfield_xxxxx
, wherexxxxx
is the custom field numerical ID, as seen in the URL when viewing or editing the field.Object value
, is the value which is same as what is expected to be returned as the result of a Groovy expression
You can use this method on any Issue
object, such as the one provided by the issue
, linkedIssue
and parentIssue
variables, as well as the Issue
objects returned by other methods such as getParentObject
()
, getEpic()
or getLinkedIssues()
.
Method availability:
This method is allowed only in scripts run from the
- Groovy script tester admin page: When you call this method on any Issue object passing the
<field_name>
or<field_id>
andObject value
, inGroovy script
of the Groovy script tester page and test it, the specified field gets set to the specified value. This is useful when you want to just set a field value without the need to trigger any transition or add a post-function.- Example: Set the Fix Version/s of the parent to the child
- Go to the JMWE administration pages
- Click on Groovy script tester
Write the following script in
Groovy script
parentIssue.setFieldValue("Fix Version/s",issue.get("fixVersions"))
Click on
Test Groovy script
from the toolbar- Select the child
Issue key
on whose parent you wish to set the value - Click on
Test
- Go to the parent issue
- Example: Set the Fix Version/s of the parent to the child
The Fix Version/s will be set to that of the child.
- Scripted (Groovy) operation on issue post-function: When you call this method on any Issue object passing the
<field_name>
or<field_id>
andObject value
, inGroovy script
of Scripted (Groovy) operation on issue post-function and trigger the transition on an Epic, the specified field gets set to the specified value.- Example: Add all the Reporters of the stories as the Watchers of the Epic
- Add the post-function to a transition
Write the following script in
Groovy script
Set users = [] issue.stories.each{ users += it.get("reporter") } users += issue.get("watches") issue.setFieldValue("watches",users)
Publish the workflow
- Trigger the transition on the Epic
- Example: Set the description of the issue with the summary and issue key
- Add the post-function to a transition
Write the following script in
Groovy script
issue.setFieldValue("description","Create a document for the fix : ${issue.key} - ${issue.summary}")
Publish the workflow
- Trigger the transition on the issue
- Example: Add all the Reporters of the stories as the Watchers of the Epic