Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Set value in version picker

Dan27
Contributor
July 25, 2018

Hi,

What is the code for setting a string value (text field) into "Fix version/s" (Version Picker)?

this String exists in the versions list.

 

thanks

1 answer

1 accepted

Suggest an answer

Log in or Sign up to answer
0 votes
Answer accepted
PD Sheehan
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 Champions.
November 22, 2021

Are the subtasks created by some sort of existing automation? If so, can you share what you have so far?

Or are these manual subtasks created by the user via the UI and you only need to automate the date field?

If so, do the parent task and the sub-task share the same workflow? Or are they different workflows?

You should be able to copy the date from the parent in a postFunction on the Create transition for the sub-task workflow.

If you have a recent version of scriptrunner, you don't even need a script. You can just use the "copy field values" feature.  Never mind that ... it won't work because of your need to have 5 days before

If you really want to use a script, it would look like this

import com.atlassian.jira.component.ComponentAccessor
if(issue.parent){
def originalDueDateCf = ComponentAccessor.customFieldManager.getCustomFieldObjectsByName('Original due date')[0]
def dueDateCf = ComponentAccessor.customFieldManager.getCustomFieldObjectsByName('Need By date')[0]
def originalDueDate = issue.parent.getCustomFieldValue(originalDueDateCf )
if(originalDueDate ){
issue.setCustomFieldValue(dueDateCf, originalDueDate-5)
}
}

 

Ravi Kanth
Contributor
November 22, 2021

Thanq so much for the reply

Ravi Kanth
Contributor
November 22, 2021

 Autopouplate Datefield.png

Ravi Kanth
Contributor
November 22, 2021

Hi ,

when i was trying to test the scripting was showing error.

 

 

Thanks.

PD Sheehan
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 Champions.
November 23, 2021

Try using "parentObject" instead of parent.

def originalDueDate = issue.parentObject.getCustomFieldValue(originalDueDateCf )
Like Ravi Kanth likes this
Ravi Kanth
Contributor
November 23, 2021

Hi Peter,

I Thanqu so much that the code worked.

Thanqu for ur reply.

 

N.Ravikanth

TAGS
AUG Leaders

Atlassian Community Events