I have a script in Jira Data Center, but the context is different and I'm having trouble adapting the code to script runner cloud
How can I declare this in cloud?
Hi @Edimara ,
The code you need is this:
def projectKey = issue.fields.project.id
def project = get("/rest/api/3/project/$projectKey")
.asObject(Map)
.body
def projectCategoryName = project.projectCategory?.name
logger.info(projectCategoryName)
if(project.projectCategory == null){
// code to execute if there is no project category
}
Just to clear up the logic, if you have the issue, we can see from the GET Issue API documentation that you have the project object, which includes the ID.
Once we have the ID, we need to get the project itself, so do the GET Project API call. This is the equivalent of ".getProjectObject()". We can see from the GET Project API documentation that the response includes not only the Project Category, but also the additional information such as the name, so we don't need another API call and can access it directly.
Hope this helps!
Join us June 26, 11am PT for a webinar with Atlassian Champion Robert Hean & Loom’s Brittany Soinski. Hear tips, stories, and get your burning questions answered. Learn how Loom makes training and enablement easier. Don’t miss it!
Register today
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.