Setting Tempo Account field to default value with ScriptRunner

Chris Roberts March 3, 2019

I have come across multiple questions related to this topic, but I have been unsuccessful in implementing any of the recommended solutions.

The thread most closely related appears to be:  https://community.atlassian.com/t5/Jira-Core-questions/Tempo-Account-field-values-with-Script-Runner/qaq-p/296415

But there is no real clear solution provided.

I am simply trying to assign a specific Tempo Account value when a new issue is created based on the issue type itself.  I have no issues setting any system field/value default, but when I attempt to set a Custome field/value and specifically the Account field/value, I cannot get it to work properly.  The Code Block below is set to trigger the behaviour on the create action for a Defect in this project.  I am trying to set the value of the Account field to the "General" Account.  The syntax seems to be correct, but I still get an Account value of "None" when I attempt to create the issue of type Defect.  Any additional guidance would be welcome.

 

import com.atlassian.jira.component.ComponentAccessor

if (getActionName() != "Create Issue") {
return // not the initial action, so don't set default values
}

// set a select list value -- also same for radio buttons
def defectAccount = getFieldByName("Account")
def optionsManager = ComponentAccessor.getOptionsManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def customField = customFieldManager.getCustomFieldObject(defectAccount.getFieldId())
def config = customField.getRelevantConfig(getIssueContext())
def options = optionsManager.getOptions(config)
def optionToSelect = options.find { it.value == "General"}
defectAccount.setFormValue(optionToSelect.optionId)

 

1 answer

0 votes
Yogesh Mude
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 5, 2019

HI @Chris Roberts 

Have you fixed this?

Julia K
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 19, 2020

Same question. Do you have a solution for this? @Chris Roberts @Yogesh Mude 

Yogesh Mude
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 19, 2020

Hello @Julia K ,

I used the JMWE app post function to set the Tempo account.

StephanieC June 2, 2023

Is this possible to do using ScriptRunner? 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events