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

Behaviour initializer fails with No such property b for class Edited

 Hello

In Adaptavist ScriptRunner Behaviour with initializer configured for a script "screen-init.groovy" with method "run",

I receive following exception for each execution:

2019-09-24 14:41:50,119 http-nio-8080-exec-84 ERROR [...] /rest/scriptrunner/behaviours/latest/validators.json [c.o.jira.behaviours.BehaviourManagerImpl] Validation exception.
groovy.lang.MissingPropertyException: No such property: b for class: screen-init
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:66)
at groovy.lang.MetaObjectProtocol$setProperty.call(Unknown Source)
at com.onresolve.jira.behaviours.BehaviourManagerImpl$_runValidator_closure9.doCall(BehaviourManagerImpl.groovy:216)

And I do not understand what is wrong and where this "b" comes from.

Here is the script content:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.bc.project.property.ProjectPropertyService

def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def projectId = getIssueContext().getProjectObject().id
def projectPropertyService = ComponentAccessor.getComponent(ProjectPropertyService.class)
def enabledProperty = projectPropertyService.getProperty(user, projectId, "enable-choice")

def firstField = getFieldByName("First")
def secondField = getFieldByName("Second")

if (enabledProperty?.isValid()
&& enabledProperty.getEntityProperty()?.isDefined()
&& "1".equals(enabledProperty.getEntityProperty()?.get()?.getValue())) {
if (secondField) {
secondField.setReadOnly(true)
}
if (firstField) {
firstField.setReadOnly(false)
}
} else {
if (secondField) {
secondField.setReadOnly(false)
}
if (firstField) {
firstField.setReadOnly(true)
}
}

 

And it seems to me that behaviour executes properly when invoking concerned screen...

So is there a way to get rid of these exceptions in Jira log file?

Thank you in advance for your help

 

 

 

 

1 answer

1 accepted

1 vote
Answer accepted

Apologies for the delay in answering this.

When running behaviours from a file you need to add some extra imports.

We mention this here

But essentially add this to the top of your script:

import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript

@BaseScript FieldBehaviours fieldBehaviours

Regards

Matthew

Correct. I have already these statements for most of my behaviors but not in some initializers. Thank you for your support.

@Matthew Clark This information seems to be missing from the current docs.

I understand it is hard to find and have raised an internal bug already to make it more obvious in the guide.

It is under the heading "Tip for IDE users" which is just under this section here.

I think if we just make a new heading for this it will make it easier to find so I will suggest that.

Regards

Matthew

Suggest an answer

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

Do Not Lose your Customer’s Trust

Missing deadlines is one of the biggest problems every team lead wants to avoid when dealing with managed services. When the customer contracts your company to help with IT services it is expected th...

24 views 0 0
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