Do Scriptrunners "Scripted Fields" Cause Much Server Load?

We are starting to use scripted fields more and more and I was curious about the server load this may cause. Is it anything to worry about? Currently we use 1-2 scripted fields per issue in a system with 33k issues and I haven't noticed any problems whatsoever.

Thanks for your time.

1 answer

1 accepted

This widget could not be displayed.

It depends what you do with them. It's really impossible to say much more without knowing what your code does.

You could time a full reindex with and without the script fields... the time difference will give you a very basic idea of the amount of additional work they are doing.

But in terms of ability to blow yourself up, script fields are at the more dangerous end of the spectrum. Novices should probably steer clear until they are familiar with jira, and the API.

 

Hi Jamie,

thanks for the super fast reply! I'll take it into consideration and make sure we are careful when there is no way around scripted fields.

We use the scripted fields to pass Cost ID values along Issue Links. We have a three / four level issue hierarchy and the Cost ID is entered at the top and inherited from there.

This is the cost ID script, the others are only a few line. This is more for information, obviously I can't expect a code review...

import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.customfields.view.CustomFieldParams
import com.atlassian.jira.issue.link.LinkCollection;
import com.atlassian.jira.issue.link.IssueLinkType;
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.fields.CustomField
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();
String second = "Cost-ID not defined"
if (issue.issueTypeObject.name == "Sub-Task") {
	if (issue.parentObject != null) {
		if (issue.parentObject.issueTypeObject.name == "Demand Task") {
			def Issue parent = issue.parentObject;
			def field2 = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Project Cost-ID");
			def String type = parent.getCustomFieldValue(field2);
			if (type == null) {
				CustomField cf = customFieldManager.getCustomFieldObjectByName("Client Cost-ID");
				Map cfVal = parent.getCustomFieldValue(cf) as Map;
				if (cfVal) {
					second = cfVal.get("1");
				}
			} 
			else{
				def field3 = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Project Cost-ID");
				second = issue.parentObject.getCustomFieldValue(field3);
			}
		}
		else{
			def field = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Cost-ID");
	        second = issue.parentObject.getCustomFieldValue(field);
		}
		
	} 
	
}
if ((issue.issueTypeObject.name == "EPIC Task")||(issue.issueTypeObject.name == "Implementation Task")||(issue.issueTypeObject.name == "Activity")) {
List inwardIssues = ComponentAccessor.getIssueLinkManager().getLinkCollectionOverrideSecurity(issue).getInwardIssues("Hierarchy");
if ((inwardIssues != null) && (inwardIssues.size() == 1)) {
  def parent = inwardIssues[0];
  def field2 = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Project Cost-ID");
  def String type = parent.getCustomFieldValue(field2);
  if (type == null) {
	CustomField cf = customFieldManager.getCustomFieldObjectByName("Client Cost-ID");
	Map cfVal = parent.getCustomFieldValue(cf) as Map;
		if (cfVal) {
			second = cfVal.get("1");
		} 
	} else {
		def field3 = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Project Cost-ID");
        second = parent.getCustomFieldValue(field3);
	}
	
}  
}

if ((issue.issueTypeObject.name == "Defect")||(issue.issueTypeObject.name == "User Story Task")) 
{
List inwardIssues = ComponentAccessor.getIssueLinkManager().getLinkCollectionOverrideSecurity(issue).getInwardIssues("Hierarchy");
if ((inwardIssues != null) && (inwardIssues.size() == 1)) {
  def parent = inwardIssues[0];
  def field =  ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Cost-ID");
  second = parent.getCustomFieldValue(field);
} 
}   
return second;

I don't think that's a problem. What I would look for is things like connecting to external databases etc... only way of telling though is with a profiler.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Tuesday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

137 views 1 3
Join discussion

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