Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to retrieve custom project properties in jira workflow scripted condition

Edited

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

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
Community showcase
Published in Apps & Integrations

🍻🍂Apptoberfest Update: Upcoming Virtual Events 🎉

Hello Community! I hope you've been enjoying the 🍂Apptoberfestivities🍂 (I know I have!) The event is heating up next week with a series of virtual events that we're calling the 🍻🍂Partner App ...

78 views 1 6
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you