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!
Want to make your everyday Community actions directly contribute to reforestation? The Atlassian Community can achieve this goal by liking a post, attending an ACE, sending your peers kudos, and so much more!
Help us plant more trees
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.