Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

scripted default value on issue creation screen

Ireen Klein_Actonic
Contributor
July 29, 2018

We use a custom field "Student". When an issue is created a default value should be set. It should be the current user.

I have no programming skills, but we use scriptrunner. Somebody an idea?

Thank you very much for your advice!

1 answer

0 votes
Alexey Matveev
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.
July 29, 2018

Hello,

It would be something like this:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption

def user = ComponentAccessor.getJiraAuthenticationContext.getLoggedInUser()
def studentCF = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Student")
issue.setCustomFieldValue(studentCF, user)
ComponentAccessor.getIssueManager().updateIssue(user, issue, EventDispatchOption.ISSUE_UPDATED, false)

Put this script into a scripted post function and put this post function last in the list of post functions.

Ireen Klein_Actonic
Contributor
August 2, 2018

It should already be visible when the create issue screen is seen.

Alexey Matveev
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.
August 2, 2018

Then it should be a behaviour with a script like this:

import com.atlassian.jira.component.ComponentAccessor

if (getActionName().equals("Create") {
def user = ComponentAccessor.getJiraAuthenticationContext.getLoggedInUser()
def studentCF = getFieldByName("Student")
studentCF.setFormValue(user);
}
Ireen Klein_Actonic
Contributor
August 5, 2018

Hello,

I solved this issue now by using Live Fields with the following script:

string currentUser=currentUser();

if(argv["screen"]=="create") {
lfSet("Student",currentUser);
}

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, likes for trees, atlassian community, social impact, tree planting campaign, community kudos, atlassian giving, environmental impact, sustainability, likes for good, atlassian social responsibility, community challenge

Make every click count—help us plant 50,000 trees! 🌳

Want to make your everyday Community actions directly contribute to reforestation? The Atlassian Community can achieve this goal by liking a post, attending an ACE, sending your peers kudos, and so much more!

Help us plant more trees
AUG Leaders

Atlassian Community Events