Scriptrunner Cloud Behaviours - Get issue status

andy_johnston
Contributor
August 7, 2024

I've been using behaviours on cloud, and I'd like to display a message on a particular issue, when it reaches a particular status.

But.... I'm struggling with the issue status.  I've got it via trial and error on the API (see below)... but surely I can get it off context?  But I'm just not sure of the syntax?

-----------------

I tried this:

 

//This didn't work returned argument of type "status" not assignable
const issueStatusFieldVal = getFieldById("status");
-----------------
I got this working - but surely there must be a better way?  Can someone help me to get the status straight from context.extension..... (I tried a few ways but didn't work)

 

//Get this issue key
const context = await getContext();
const thisIssueKey = context.extension.issue.key;
//From the issue key get the status of the issue
const requestTextString = "/rest/api/3/issue/" + thisIssueKey.toString() + "?fields=status"
const res = await makeRequest(requestTextString);
const thisIssueStatus = res.body.fields.status.name

1 answer

0 votes
Kristian Walker _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 29, 2024

Hi Andy,

The context provided by Atlassian when a behaviour is very limited.

This means the way to get the status is to get the issue object using the key out of the context and to return the status out of this.

You could do this using the example code I have provided in the snippet file located here.

I hope this answer helps.

Regards,

Kristian

 

 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events