Script runner help for scripting about field values

I realize I really dont understand the documentation about JIRA Script runner because there is absolutely no example of what I'm looking for. Could you help me ?

I'm looking for 2 scripts.

  1. Change the priority of an issue by detecting the a word in the description. I don't know how to get the description and how to do a contains search. I would like to change the priority to urgent when the description contains the "urgent" word.
  2. Copy the story points value to the original estimate. I would like to copy story points to days with a velocity factor. Velocity can be hardcoded for this first version. Each point is a day * velocity.

Thank you.

 

2 answers

Hello, 

Story points is a custom field. You can access it like this:

 

import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.MutableIssue;
 
 
CustomFieldManager customFieldManager = ComponentManager.getInstance().getCustomFieldManager();
  
CustomField customField_name = customFieldManager.getCustomFieldObjectByName( "customfield_name" );
customfield_value = issue.getCustomFieldValue( customField_name))
The original estimate can be set like this:
issue.setEstimate(Long estimate)  //estimate should be given in seconds

I finally found hoe to set the priority

 

import com.atlassian.jira.issue.MutableIssueif (issue.summary.contains("Urgent") || issue.summary.contains("URGENT")) {    MutableIssue mutableIssue = (MutableIssue) issue;    mutableIssue.setPriorityId("2");}

I'm sill looking for my point two.

I hate people that downvote without explanation. Then what? Doesn't help at all.

I know, especially when someone fixes their own problem.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 29, 2018 in Marketplace Apps

How to set up an incident workflow from the VP of Engineering at Sentry

Hey Atlassian community, I help lead engineering at Sentry, an open-source error-tracking and monitoring tool that integrates with Jira. We started using Jira Software Cloud internally last year, a...

1,448 views 0 8
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