Hi,
Want to copy value updated in Single line text custom field (i,e Doc Version) to Multi line text custom field (i,e All Versions) using Groovy script?
//assuming this is a sigle line text field
def textFieldA = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName(
"Doc Version"
)
//assuming this is a Multi line text field
def textFieldB = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName(
"All Versions"
)
issue.setCustomFieldValue(textFieldB, textFieldA
) ==> is it appends values???
The "Doc Version" custom field value will get updated by issue assignee multiple times in my workflow @ different workflow transition steps.
I want to save all the version updated by assignee instead of overwriting it, I am trying to copy values into another Multi line text custom field i,e All Versions for Team's future reference.
Is this the right way or using one Multie line text custom field itself, we can try to preserve the previous values and get appended with latest version values using only one field itself? Please advice.
Manju
Got it, the below script works as per my requirement.
'\n' between prev and current field value adds new line between 2 values. It works. Thanks.
import com.atlassian.jira.issue.Issue import com.atlassian.jira.issue.fields.CustomField import com.atlassian.jira.component.ComponentAccessor CustomField textFieldB = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("SDD Document All Versions") issue.setCustomFieldValue(textFieldB, String.valueOf(issue.getCustomFieldValue(textFieldB)) + '\n' + String.valueOf(issue.getCustomFieldValue(ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("SDD Baselined Doc Version"))))
Try this code
import com.atlassian.jira.issue.Issue import com.atlassian.jira.issue.fields.CustomField CustomField textFieldB = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("All Versions") issue.setCustomFieldValue(textFieldB, issue.getCustomFieldValue(textFieldB) + issue.getCustomFieldValue(ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Doc Version")))
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for your prompt response Vasiliy.
I am getting the below ERROR, when I tried to use the script you had suggested in Custom script post-function.
Static Type Checking - cannot find matching method
java.lang.Object#plus(java.lang.Object). Please check if declared type is right and if method exists
Possible solutions: use([Ljava.lang.Object;), is(java.lang.Object), use(java.lang.Class, groovy.lang.Closure), split(groovy.lang.Closure), wait(), find() @ line 8, column 39.
I am using JIRA Software 7.2.7 and SR version is 4.3.16
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vasiliy,
Was trying alternate option of Using "Update Issue Custom Field" Add Post Function To Transition, updates an issue custom field to a given value. So I am trying to get the value from another custom field and trying to append it to the another 'Issue Custom Field' using this post function.
But I am unable to get the value of Custom Field Value from custom field id i,e customfield_10104
1) Issue Custom Field: SDD All Versions
2) Custom Field Value: customfield_10104 ==> this is another cusomt field id, from which I am trying to copy the value to 'SDD All Versions' custom field) here simply entering the ID of the option to be selected to get the value.
Append value: | If set, the given value will be appended to the field. Or if field supports multiple values, then the given value will be set without unsetting other ones. |
Please make sure that the value you enter is valid for custom field its datatype and context configuration for the project using this workflow. Otherwise, the transition may fail at execution time. Additionally to enter text or numbers as value, you may use the following:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Lets try this one:
import com.atlassian.jira.issue.Issue import com.atlassian.jira.issue.fields.CustomField CustomField textFieldB = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("All Versions") issue.setCustomFieldValue(textFieldB, String.valueOf(issue.getCustomFieldValue(textFieldB)) + String.valueOf(issue.getCustomFieldValue(ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Doc Version"))))
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Vasiliy Zverev.
The shared script is able to append the values, but is it possible to copy values into "All Versions" from "Doc Version" into new line? As "All Versions" customfield is a Multi line Text.
So that reading values will be easier for JIRA Assignee's reference. Please advice how to do this in the shared script. Thanks.
Doc Version: 012345 (first time updated value)
Doc Version: 67890 (second time updated value)
All Versions:
012345
67890
and so on.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The appended values started with "null" value. How to remove the "null" from the result
RPA-Cumu-Fulfilled-Res-Offshore:null[104294 - Bhandary,Venugopala, 104842 - Shaikh,Anjumaara Mubarak]
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Manjunatha K R @Tushar @Vasiliy Zverev at which place i should run this scrtipt?? i am running this in behavior am getting an error for the issue. the "issue" variable is undeclared?.please help me out where should i run this script?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is for postfunction, condition or a validator. In these cases there is a variable issue is defined and represents cuurent issue.
To run it separatelly you should define this variable of class Issue or MutableIssue.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.