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!
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.