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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Different Workflows with same tranistion/status run both scripts on transition

I have 2 workflows with the same transitions (Ready for Work) and statuses (In Progress).  Each workflow has a post function.

Looking at the logs, I noticed that when I go through the workflow of one, both scripts are run.  

Do I have to create a new status for one of the workflows when I need to run a script?

Thanks,

Martha

2 answers

0 votes
Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Oct 26, 2023

I wonder if by copying a workflow, the postfunction script unique ID is replicated in the new workflow.

This could cause the logs from one workflow's execution to be displayed in both workflow.

But I doubt the workflow actually executed twice. You could confirm this by adding some logging to the script to output which issue it was run on and some other random number (.eg.

log.info "This script was executed for $issue.key. RandomUUID to verify uniqueness of execution: ${UUID.randomUUID().toString()}"

To fix this, delete your post-function and re-create it.

This would warrant a bug report to adaptavist.

I realized that for that particular post function, I had repurposed a copied one.  New post functions I created didn't show the same problem.  Once I deleted it completely and recreated it, the log problem stopped.  So yes, apparently the script ID was retained when the workflow was copied.  Thanks for the help!

0 votes
John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Nov 17, 2020

Hi @mf  - Welcome to the Atlassian Community!

Can you provide some more details about the "script"? Are you using an Automation For Jira rule? A ScriptRunner script? Etc.  

Where is the "script" placed? Can you share it? 

Hi John,

The ScriptRunner script is in multiple workflow post functions. the function iterates a field that has a list of projects and creates an Epic in each of those projects.  

Below is a screenshot of the list of ScriptRunner Post functions.  You can see in the history that the scripts all ran at the same time.  Each one is in a different project and different workflows.  It appears if I use the Ready for Development (81) transition in multiple places, when it is run for 1 workflow it is run for all workflows with Ready for Development transition.

Also - I am working in the cloud version.

 

ThanksWorkflow2.pngWorkflows.png

I'm running Data Center 8.20.13 and seeing the same thing.  I copied a workflow shared across many projects and put the copy in a workflow scheme for a single project.  I added a ScriptRunner "create a sub-task" post condition to one transition in the copy, triggered off of a checkbox field specific to that project.  Now the execution history for that post condition on the copied workflow shows log entries for the original workflow and that transition ID.  They are all green checks and ScriptRunner says "No failures in the last 15 executions", but they all say "ERROR [utils.ConditionUtils]: Workflow condition script has failed on issue...  java.lang.NullPointerException: Cannot invoke method contains() on null object" 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events