SIL script custom field not in context

Hi there,

we are using a few SIL scripted fields. Recently we saw in our log files a bunch of "Field not available in context" warnings for them also giving a reference to the issue where that happened.

The SIL field in question is restricted to one issue type but global for all projects. Some of the projects use the issue type without that SIL field, so we took it off their screens. But these issues are now shown in the error log. Somehow the SIL script is being executed for these issues even tho they dont use it.

Thes script looks like this:

string riskImpact     = customfield_10401;
string riskLikelihood = customfield_10402;
number riskCost = customfield_11017;
   
if (riskLikelihood == "Rare") {
   return riskCost * 0.1; 
}
else if (riskLikelihood == "Unlikely") {
   return riskCost * 0.3; 
}
else if (riskLikelihood == "Possible") {
   return riskCost * 0.5; 
}
else if (riskLikelihood == "Likely") {
   return riskCost * 0.8; 
}
else if (riskLikelihood == "Almost certain") {
   return riskCost * 0.99; 
}
else
   return "n/a";

The SIL field itself and customfield_11017 are not in the context of the issue. Why is the SIL script executed anyway? Just because it is assigned to the issue type?

Is there a way in SIL script language to check on the existence of customfields in the context before accessing it? Something like "if (isset(customfield_11017)) ... ?

Best regards,
George

1 answer

1 accepted

Hi Geroge,

Check out the isCustomFieldInContext routine: http://confluence.kepler-rominfo.com/display/SIL/isCustomFieldInContext.

You can use it like this: if(isCustomFieldInContext("customfield_11017", project, issueType)) { ... }.

The SIL script for the SIL field gets executed because the field is in the issue context, being associated to the issue type and it is a calculated custom field.

Kind Regards,

Alex

Note: To clarify, the SIL script is called every time somebody asks for its value. You may have a plugin that gets all the CFs, or even JIRA may ask for it.

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:...

818 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