Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Listener Clone ticket is not updating a CF after creation Edited

Hi,

I am trying to use lister to clone a ticket when the original ticket is resolved and update the ticket cloned ticket with CF x to CF Y

My current settings are:

condition: 

cfValues['Request Type']?.value == 'X'

Additional issue actions:

import com.atlassian.jira.component.ComponentAccessor

import com.atlassian.jira.issue.Issue

import com.atlassian.jira.issue.ModifiedValue

 

def cf = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Request Type")

issue.setCustomFieldValue(cf,'Y')

issue.setAssignee(null)

I also tried: 


def cf = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'Request Type'}
issue.setCustomFieldValue(cf,'Y')
issue.setAssignee(null)


so the ticket is cloned and the relevant fields are copied but the request type is X and not being modified to Y. It is not even showing up on the cloned ticket so I believe the value is being 'null'...
any idea what I am doing wrong?
thanks,

1 answer

Hi

If you are trying to update custom field from listener you should use mutableIssue .

Here is an example how to update issue custom field from script runner listener: https://community.atlassian.com/t5/Jira-questions/Changing-custom-field-in-Listener-not-re-indexing-issue/qaq-p/902472#M289567

Thanks Fydor - ill test and let you know the results...

 

FYI - the listener already have an examples built in, this is where I took the code for: 

def cf = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Request Type")

issue.setCustomFieldValue(cf,'Y')

and I tested by changing the summary to include the new value using:

issue.summary = "Request Type value is: " issue.getCustomFieldValue(cf)

and the summary of the new issue shows "remove" - the only thing that doesn't actually get updated is the custom field value.... so weird...

Unfortunately it did not work

I can clone all the relevant fields into the new ticket (needs less fields from the original one), but this specific field for the request type is not getting updated.

I also tried to index, but nothing helps

might be my groovey version (5.0.11) or my Jira (7.3.4)

But I cannot accept the answer as the field has not updated

I also tried to set the assignee - and it works only if assignee in null:

issue.setAssignee(null)

but 

issue.setAssignee(UserManager.getUserByName("{usr_name}")) did not work

Hello

Hmm, this is strange.
Probably it is related with custom field type (string, number, select option...)- for.e.g you are trying to update number custom field with string value?
I recommend you to check your Jira version API, probably there are some changes in methods and classes - https://docs.atlassian.com/software/jira/docs/api/7.3.4/index.html?overview-summary.html
Also try to enable logging in your listener and check output:
....
import org.apache.log4j.Category
...
log.setLevel(org.apache.log4j.Level.<your level>)
log.info("start logging...");
....

you are correct, i'm trying to change a custom field that is a drop down and not just a text field.... maybe to do that i need the id of the value instead of the text...

will have to search the API  - unless you have some quick example for me...

thanks,

You need to get specific option and set it to your custom field.

Try something like this. 



//issueToUpdate - your target issue
def CF=customFieldManager.getCustomFieldObjectByName('Select_list');
def fieldConfig = CF.getRelevantConfig(issueToUpdate)
def optionsManager = ComponentManager.getComponentInstanceOfType(OptionsManager.class)
def optionA = optionsManager.getOptions(fieldConfig).find {it.value == "OptionA"}
issueToUpdate.setCustomFieldValue(CF, optionA);
issueManager.updateIssue(event.getUser(), issueToUpdate, EventDispatchOption.ISSUE_UPDATED, false);

 

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Marketplace Apps & Integrations

Staying organized with Jira: best practices for a better project management

Project managers know this problem: A “mountain of work” lays in front of you, and you don’t know how and where to tackle them. Different to-dos lie ahead, but just one task after the other can be ha...

272 views 2 1
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you