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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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

Behaviours error after migration JIRA server 8.5

Hello, 

we migrated from JIRA 7 to 8.5.

Now I have errors with a behavior that work great before migration.

import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.component.pico.ComponentManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.MutableIssue

ComponentManager componentManager = ComponentManager.getInstance()
Object fieldID = getFieldById("Application")

MutableIssue currentIssue = componentManager.getIssueManager().getIssueObject(Long.parseLong(fieldID.value))

FormField pr_field = getFieldById("Application")

def isPR = componentManager.getUserUtil().getGroupNamesForUser(currentIssue.getReporter
User().getDisplayName()).contains("Groupe-P2B-Application_2")

if(!isPR){
pr_field.setHidden(false)
pr_field.setRequired(true)
}

 help please ? 

Thanks,

BR

Fayçal

1 answer

0 votes
Dirk Ronsmans Community Leader Jan 13, 2021

And what exactly is the error?

Also what version of scriptrunner did you upgrade from and to?

Hello, 

this a screen shot of this error :

Sans titre.png

ScriptRunner from V 5.6.12  to V 6.16.0.

Thanks for your help. 

BR

Dirk Ronsmans Community Leader Jan 13, 2021

Can you try adding the explicit import?

import com.onresolve.jira.groovy.user.FormField

i put this code in the behaviour :

import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.component.pico.ComponentManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.MutableIssue
import com.onresolve.jira.groovy.user.FormFieldComponentManager

componentManager = ComponentManager.getInstance()

Object fieldID = getFieldById("Application")

MutableIssue currentIssue = componentManager.getIssueManager().getIssueObject(Long.parseLong(fieldID.value))

FormField pr_field = getFieldById("Application")

def isPR = componentManager.getUserUtil().getGroupNamesForUser(currentIssue.getReporterUser().getDisplayName()).contains("Groupe-P2B-Application_2")

if(!isPR){
pr_field.setHidden(false)
pr_field.setRequired(true)
}

 now i have this error : 

Sans titre.pngplease help ? 

Thanks,

Fayçal

Dirk Ronsmans Community Leader Jan 13, 2021

Well you didn't import the correct class..

 

import com.onresolve.jira.groovy.user.FormFieldComponentManager 

is not 

import com.onresolve.jira.groovy.user.FormField

I m sorry for the mistake : 

import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.component.pico.ComponentManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.MutableIssue
import com.onresolve.jira.groovy.user.FormField

ComponentManager componentManager = ComponentManager.getInstance()
Object fieldID = getFieldById("Application")

MutableIssue currentIssue = componentManager.getIssueManager().getIssueObject(Long.parseLong(fieldID.value))

FormField pr_field = getFieldById("Application")

def isPR = componentManager.getUserUtil().getGroupNamesForUser(currentIssue.getReporterUser().getDisplayName()).contains("Groupe-P2B-Application_2")

if(!isPR){
pr_field.setHidden(false)
pr_field.setRequired(true)
}

i have also this error : 

 

Sans titre.pngThanks for your help

Fayçal 

Dirk Ronsmans Community Leader Jan 13, 2021

Well I don't see anything wrong with that line of code.

I also don't find anything in the release notes that might be causing this for v6.x

Might be best to simply raise a call with Adaptavist for this to see if anything in the classes has changed that wasn't mentioned in the release notes.

Or hope for someone else to take a look and see whats wrong..

I hope so too.
Thank you for taking the time to help me

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Posted in Jira Software

Presenting the "Best of 2020" Jira Software roundup!

Catch up with Atlassian Product Managers in our 2020 Demo Den round-up! From Advanced Roadmaps to Code in Jira to Next-Gen Workflows, check out the videos below to help up-level your work in the new ...

7,142 views 8 28
Join discussion

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