How to retrieve custom project properties in jira workflow scripted condition

Vishal Kharde May 3, 2020

I would like to conditionally show a transition screen based on custom property set for a jira project. i.e if a project has a certain property set then on particular transition for a issue, it will be shown a screen with some fields to fill in values. If this property is not set, then issue will automatically transition into next state without screen prompt. I m using Jira Rest API to store the entity properties. Jira Entity 

How can I access the project custom properties(Set using Jira Rest api) in workflow script condition? 

Jira Server (Version: 8.5.1)

 

Thanks,

Vishal K

1 answer

1 accepted

0 votes
Answer accepted
Vishal Kharde May 8, 2020

Following steps and code worked for me,

1.Create a workflow condition(refer code block below) on the transition with the required screen.

2. Create a parallel transition to allow normal flow without screen and a workflow condition which sets passesCondtion as true when property values are not set.

 

Jira Rest API Used to store property: /rest/api/2/project/XYZ/properties/project_custom_id

Project Key: XYZ

Property Name: project_custom_id

import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.component.ComponentAccessor
import io.atlassian.fugue.Option
import com.atlassian.jira.bc.project.property.ProjectPropertyService
import com.atlassian.jira.entity.property.EntityPropertyService
import com.atlassian.jira.entity.property.EntityProperty
import com.onresolve.scriptrunner.runner.util.UserMessageUtil

def projectKey = issue.projectObject.name
passesCondition = false
ApplicationUser user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser();
 ProjectPropertyService pps = ComponentAccessor.getComponent(ProjectPropertyService.class);
 EntityPropertyService.PropertyResult pv= pps.getProperty(user, "XYZ", "project_custom_id");
 Option<EntityProperty> jsonValues = pv.getEntityProperty();
 def pv_value = jsonValues.getOrNull()

// Add conditional checks for the property values using pv_value.getValue() and set passesCondtion as true when required property values are set.

 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events