Forums

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

Set Select List Custom field from scriptrunner clone issue postfunction.

Vineet Kumar
Contributor
July 9, 2018

Hello Everyone, We are using Jira 7.6.4 and Scriptrunner 5.4.11, The task is to autopopulate a Selectlist customfield in Jira on the target issue. I have tried variuos scripts from the blog but none of them are working for me. Is something changed on Scriptrunner plugin recently? Can someone help me to get the correct script including the correct packages. 

 

I have tried the below scripts:

 

CustomField customField = customFieldManager.getCustomFieldObject("customfield_17100");

OptionsManager optManager = ComponentAccessor.getOptionsManager();
Options options = optManager.getOptions(customField.getRelevantConfig(issue), null));

Option newOption = options.getOptionById("Campaign"); // Check your option id

ModifiedValue mVal = new ModifiedValue(issue.getCustomFieldValue(customField), newOption );

customField.updateValue(null, issue, mVal, new DefaultIssueChangeHolder());

 

===============*=======================

 

import com.atlassian.jira.component.ComponentAccessor
def cfSelect = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("Solution")
def cfConfig = selectCf.getRelevantConfig(issue)
def value = ComponentAccessor.optionsManager.getOptions(cfConfig)?.find {
it.toString() == 'Campaign'
}
issue.setCustomFieldValue(cfSelect, value)

 

 

1 answer

2 votes
crf
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 9, 2015

Does the atlassian-jira-security.log file not have what you need?  I'm not sure it says which AD server was used when that is relevant, but it should have everything else.

What goes into that log is controlled by log4j.properties.  The relevant log messages are partially generated by seraph and partly by LoginManagerImpl.

MattS
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 Champions.
April 13, 2015

Thanks, Chris. It does except for the AD info. I poked around the source but didn't see what log name to use to show that AD info anywhere

crf
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 13, 2015

Anything specific to the implementation, like the fact that it's talking to AD, would be logged by embedded crowd rather than JIRA itself. Unfortunately, it looks like they don't log a whole lot of information about that. The only log line I see offhand with enough information to work out what happened is probably this debug line from SpringLDAPConnector: logger.debug("Authenticating user '{}' with DN '{}'", name, user.getDn()); (I assume you would probably be able to work backwards from the DN to the directory that owns it). Turning debug logging on for that class would be an unacceptable amount of log spam.

MattS
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 Champions.
April 14, 2015

Yeah, saw that. I think the easiest though annoying thing to do is to change LoginManagerImpl so that the log message "The user 'mdoar' has PASSED authentication." includes the user.getDirectoryId() info as well. It seems to work in a local test instance. Actually, it seems like that info would be useful in the atlassian-jira-security.log file anyway

Suggest an answer

Log in or Sign up to answer