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

Unable to access value stored in one behavior script to another

Hi Everyone,

I have two behavior script which works fine. Now I want to access the value  stored in one script to another. I tried accessing the value in behavior script initializer but I am getting null value.

Behavior script :

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


@BaseScript FieldBehaviours fieldBehaviours
def A = getFieldById("customfield_16355")
Object A_val = A.getFormValue() as int


def A_Hours = getFieldById("customfield_16365")

Object A_Hour = 125*A_val

A_Hours .setFormValue(A_Hour )

 

Now when I tried to get value of field which is set by using A_Hours .setFormValue(A_Hour ) in the other behavior script OR in the initializer console of behavior script but I am getting null value.

 

Could you please help me on this.

Thanks,

Suchit

1 answer

0 votes

Ok, I'll take a stab at this... I see no one is daring to answer.

The short answer is no, there is no cross-talk possible between server-side behaviour script.

The longer answer requires some explanation of what behaviour does.

When you open a screen (create, edit, transition), there is a bunch of back and forth between browser-side scripts and the jira server backup using special rest endpoints supplied by scriptrunner.

  1. Browser says:
    • hey, here is a screen for project x and issuetype y (or issue id for edit) with all the fields data currently available, are there any validators mapped that?
  2. Jira Action:
    • Jira looks at all the behaviours that match the relevant mapping and
      • looks up all the fields with some generic behaviour configuration and get their actions
      • executes each of the inilializers and gets a list of fields and action
        • any getValue() on field object is taken from the request sent by the browser
  3. Jira Responds:
    • Sure, here are all the fields that are impacted by some behaviour rule and their specific behaviour actions: readOnly, hidden, value to set etc
  4. The browser then makes the necessary adjustments to the fields
  5. The browser makes further requests for each field that have behaviours (to run their server-side script) saying. Run any validators for this field. Here are all the other field values.
  6. Jira runs those validators and sends back a list of fields and their corresponding actions.
  7. The browser makes the necessary adjustments to the fields

Then each time you modified a field included in the response listed in #3, that validator is re-un using new and updated data.

You see, each of those server-side requests are executed in a standalone transaction. So one is not aware of what is happening to the other.

Now, if you have some fields that are interdependent, you may need to combine your 2 scripts and run them from each of your fields.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira

Announcing the waitlist for Jira Work Management

Hey there Cloud Community members! We’re excited to give you the first glimpse of the new home for business teams on Jira — Jira Work Management. Jira Work Management is the next generation of J...

1,235 views 18 23
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