Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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 changelogitem using Jira Expressions in ScripRunner Workflow Condition Edited

Hello,

I'm in process of migrating a Jira server instance to Jira cloud and would like to move as many ScriptRunner items as possible.

In the server version, I have a workflow condition using Groovy that checks for a changelog with the field='status' and the toValue='To Business Analyst'.

The changelog is checked only if one of our user picker custom fields (Business Analyst) has a value.

If the Business Analyst contains a value and there's no log record of the issue status being changed to 'To Business Analyst', the workflow condition will return false.

In the Jira Expression, I have the check for the Business Analyst value and a check to see if there are existing changelogs. These seem to work fine:

issue.customfield_10041 != null &&
issue.changelogs.length > 0

 

I can test values in the changelogs as well:

issue.changelogs.filter(c => c.author.displayName == 'Jim').length > 0

 

I am, however, unable to figure out how to get to the ChangelogItem properties. I've attempted several different approaches based on examples on this page

Full disclosure, I don't typically do Web development but have been provided an 'opportunity' by having to convert the scripts.

Any help would be appreciated.

Thanks!

2 answers

Hi @Jim Litzie 

Thank you for your question.

I can confirm that the ScriptRunner for Jira Cloud plugin provides workflow Validators using the Jira Expression Framework as documented in the Atlassian API documentation page located here or in the documentation page located here which explains how to add in a new validator to your workflow.

We can confirm that when viewing the Jira Expression Framework API documentation page linked above you can navigate to the Context variables section which shows what variables are provided by this framework that can be used to create the expression.

If you then click on one of the variables it will show all the properties that can be called on the variable for the expression such as for the issue variable as shown here and you will be able to check this to see if Atlassian provides a variable that contains the item you want to check against.

We can also confirm we have some examples of validators that can be used as a reference guide in the page located here as well as in the documentation page located here.

We would recommend using these documentation pages linked above as a reference guide to help to create the validator expression that you require.

Thank you

Kind Regards

Kate

I was able to finally get something working. It looks a bit strange but seems to work ok so far.

issue.customfield_10041 == null ||
issue.changelogs.filter(c => c.items.filter(i => i.toString == 'To Business Analyst').length > 0).length > 0

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket Pipelines

Bitbucket Pipelines Runners is now in open beta

We are excited to announce the open beta program for self-hosted runners. Bitbucket Pipelines Runners is available to everyone. Please try it and let us know your feedback. If you have any issue...

237 views 4 3
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