Issue with Scripted Field Context

I created a scripted field custom field with its context set to issue type X.

However, in the Issue Navigator I am able to see the scripted field for other issue types. Is this the expected result? Here is a screenshot:

 

SC1.png

2 answers

1 accepted

We have utilized something similar in our instances.  We actually approach it from both directions, first by putting the fields "scope" in the code (usually an "if" statement checking for project and/or issue type), and second by adding a field context.  I have had much better luck scoping the context to Projects rather than issue types. 

In your scenario, there is one other thing to check, and that is to see whether or not the global context still exists.  When we use the context to scope scripted fields down, I always remove/overwrite the global context so that only the scope context exists.  I have not actually checked in the search results like your screen-shot, but what I did do was do a before context/after context count of the number of references in the logs after a re-index.  Based on the numbers I saw, the context helped significantly and was scoping properly.

An additional note as to why we use both methods:  We have some rather large JIRA instances and noticed that even though we were scoping to a specific project/issue type within the code, the script is still executing (you can see this by adding a log statement before the scoping code) and during the re-index process causes a lot of unnecessary time and system resource usage.  By adding the field context (when properly configured), the script never executes for issues that didn't meet the context criteria.

0 vote
Vasiliy Zverev Community Champion Dec 24, 2015

If you want to use scripted field only for specified type you should to define it into code.

Because values for scripted fields are calculated at every reindexing.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published May 30, 2018 in Marketplace Apps

Three tips for boosting your board's efficiency with Story Maps

Trello is one of the most effective tools for driving your sprints. It's customizable for every Agile team and product owners and Scrum masters (SM) love it. However, Agile teams often struggle with:...

849 views 2 9
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you