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 guarantee subTasks use Tempo Account "inherited from parent" select choice at create Edited

Background:

For user time accounting purposes, we must have parent issues and their subtasks have the same Accounts automatically. To make this foolproof, we plan to remove the ability to edit the Account field on Subtasks, and thus must require the choice "inherited from parent" is selected at create.

I am attempting to enforce this option through scripted post functions. Unfortunately, the workflows involved are used on both subtasks and parent issues. Splitting them up is not a maintainable option.

What I have found is that the usual scriptrunner ways of updating fields (issue.setCustomFieldValue(...)) do not work for this. This will set the account to the parent issue's account, but the subtask's account will not be dynamic. If the parent issue's account changes, the subtask will remain on the old account.

I have found that using the JIRA Suite Utilities "Update Custom Field Value" and setting the account field to a value of 0 (which is what the UI sends when the inherit option is chosen) works as expected. However, this of course overrides any non-subtask's account as selected at create. It also does not work with issue.setCustomFieldValue(). So, to get the post function to only apply to subtasks, I need to be able to call the JIRA Suite Utilities update function within a scriptrunner function (if this is indeed possible).

Actual Issue:

My attempts to call the JIRA Suite Utilities function in a post script are failing:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.event.type.EventDispatchOption
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.atlassian.jira.issue.util.IssueChangeHolder
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.user.ApplicationUser
import com.opensymphony.module.propertyset.AbstractPropertySet
import com.opensymphony.module.propertyset.PropertySet
import java.util.Map

@WithPlugin('com.googlecode.jira-suite-utilities')

def updateIssueCFPF = ComponentAccessor.componentClassManager.loadClass('com.googlecode.jsu.workflow.function.UpdateIssueCustomFieldPostFunction')
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def accountCF = customFieldManager.getCustomFieldObjectByName("Account")

if (issue.isSubTask())
{
    def propertySet = accountCF.getPropertySet()
    Map args = ["customfield_11100": "0"]
    updateIssueCFPF.execute(transientVars, args, propertySet)
}

The error I'm getting as a failure:

2018-01-10 11:58:18,316 ERROR [workflow.ScriptWorkflowFunction]: *************************************************************************************
2018-01-10 11:58:18,316 ERROR [workflow.ScriptWorkflowFunction]: Script function failed on issue: null, actionId: 1, file: <inline script>
groovy.lang.MissingMethodException: No signature of method: static com.googlecode.jsu.workflow.function.UpdateIssueCustomFieldPostFunction.execute() is applicable for argument types: (java.util.HashMap, java.util.LinkedHashMap, com.atlassian.jira.propertyset.CachingOfBizPropertySet) values: [[entry:com.opensymphony.workflow.spi.SimpleWorkflowEntry@373df8bc, ...], ...]
Possible solutions: execute(java.util.Map, java.util.Map, com.opensymphony.module.propertyset.PropertySet)
	at Script30.run(Script30.groovy:24)

I have tried many ways to declare or cast the arguments to the requested types, but they still get passed in as the original types.

 

2 answers

1 accepted

0 votes
Answer accepted

I ended up resolving this in an entirely different manner. I added the initial value of the Accounts field to the transient vars, set the Account to 0 via the post function, then conditionally restored the original value from transient vars.

Is this working?

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase

The benefits of using Jira in different departments

Jira is a great tool to use across different departments. Forget that paperwork – switch to Jira and get that tasks done smoothly. Marketing Jira allows for a complete digital transformation of you...

97 views 0 5
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