Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,559,114
Community Members
 
Community Events
184
Community Groups

script groovy with getissue

hello,
 
we use a script Groovy (plugin Scriptrunner) in Jira 7 to create a new issue from a workflow to an another workflow
 
we use "import com.atlassian.jira.issue.IssueFactory" like this:
 
IssueFactory issueFactory = ComponentAccessor.getComponent(IssueFactory)
[...]
MutableIssue newIssue = issueFactory.getIssue()
 
but with Jira 8, the value newIssue returns null.
 
can you help us please so "issueFactory.getIssue()" works correctly? what shall we modifiy ?
 
Thanks
 

1 answer

0 votes
Dirk Ronsmans
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Oct 21, 2021 • edited

Hi @linda_zghendy ,

Going by the documentation https://docs.atlassian.com/DAC/javadoc/jira/reference/com/atlassian/jira/issue/IssueFactory.html that seems like it should to be an easy thing.

  • Have you tried wrapping the creation in to a try/catch block to see if it is throwing any exceptions?
  • Does the log show any message when the code is executed?
  • Have you tried just generating an issue thru the script console (without any other actions around it to rule out interference)?

If you can post some more of your script we might be able to see if something else has changed.

Also as a reference you can always look thru https://library.adaptavist.com for example scripts.

I personally tend to use the IssueManager interface more which allows me to validate the input first before actually running the create.

Hi Dirk, thanks for your answer

 

here copy from script :

IssueFactory issueFactory = ComponentAccessor.getComponentOfType(IssueFactory.class)

 [..]

 MutableIssue newIssue = issueFactory.getIssue()

 […]

 DefaultIssueChangeHolder issueChangeHolder = new DefaultIssueChangeHolder()

def groupManager2 = ComponentAccessor.getGroupManager()

def group2 = groupManager2.getGroup(groupValue.toString())

CustomField groupeField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_10123")

List<Group> groupList = new ArrayList<Group>()

groupList.add(group2)

if (groupeField.getValue(newIssue).equals(null)) {

                log.warn "Creation value groupe Etude"

    groupeField.createValue(newIssue, groupList)

 

}else{

 

[…]

 

}

 

here copy from log error :

[...]

2021-10-21 17:27:51,308 WARN [runner.ScriptBindingsManager]: Creation value groupe Etude

2021-10-21 17:27:51,436 ERROR [workflow.AbstractScriptWorkflowFunction]: Workflow script has failed on issue ASK-10516 for user 'S081846'. View here: http://fr-pe-jira-w1:8[...]

com.google.common.util.concurrent.UncheckedExecutionException: java.lang.NullPointerException: null value in entry: issue=null

                at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2050)

[...]

                at Script63.run(Script63.groovy:111)

Caused by: java.lang.NullPointerException: null value in entry: issue=null

                at com.google.common.collect.CollectPreconditions.checkEntryNotNull(CollectPreconditions.java:32)

                at com.google.common.collect.SingletonImmutableBiMap.<init>(SingletonImmutableBiMap.java:42)

                at com.google.common.collect.ImmutableBiMap.of(ImmutableBiMap.java:72)

                at com.google.common.collect.ImmutableMap.of(ImmutableMap.java:124)

                at com.atlassian.jira.issue.customfields.persistence.EagerLoadingOfBizCustomFieldPersister.lambda$getValuesForIssueId$1(EagerLoadingOfBizCustomFieldPersister.java:115)

                at com.google.common.cache.LocalCache$LocalManualCache$1.load(LocalCache.java:4876)

[...]

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events