Copy Value from cascading list to custom field

Hi,

I am trying to copy first value of cascade select list to a custom text field "Business" and second value to security level.

I was earlier using below groovy on create issue post function to copy first value of cascade list to security level.

import org.apache.log4j.Category
import com.opensymphony.user.User
import com.googlecode.jsu.util.WorkflowUtils
import com.atlassian.jira.issue.security.IssueSecuritySchemeManager
import com.atlassian.jira.issue.security.IssueSecurityLevelManager
import com.atlassian.jira.ManagerFactory
import com.atlassian.jira.ComponentManager
import org.ofbiz.core.entity.GenericValue


def log = Category.getInstance("com.onresolve.jira.groovy.MriskCondition")

ComponentManager componentManager = ComponentManager.getInstance()
IssueSecurityLevelManager securityLevelManager = componentManager.getComponentInstanceOfType(com.atlassian.jira.issue.security.IssueSecurityLevelManager)

IssueSecuritySchemeManager issueSecuritySchemeManager = ManagerFactory.getIssueSecuritySchemeManager()
IssueSecurityLevelManager issueSecurityLevelManager = ManagerFactory.getIssueSecurityLevelManager()

GenericValue srcProjectGV = issue.getProject()
log.debug(srcProjectGV)
def issueSecurityScheme = issueSecuritySchemeManager.getSchemes(srcProjectGV).size() == 0 ? null : issueSecuritySchemeManager.getSchemes(srcProjectGV)[0]

User currentUser = componentManager.getJiraAuthenticationContext().getUser()

def sourceFieldName = "customfield_10572"

def sourceFieldVal = WorkflowUtils.getFieldValueFromIssue(issue, WorkflowUtils.getFieldFromKey(sourceFieldName))
sourceFieldVal = sourceFieldVal.getKeysAndValues()


if ( sourceFieldVal != null ) {
def business = sourceFieldVal[null][0]
log.debug("business: '$business'" )
def secLevelGvList = issueSecurityLevelManager.getUsersSecurityLevels(issue.getGenericValue(), currentUser)
log.debug(secLevelGvList)
def secLevelGv = secLevelGvList.find ({ it.get("name") == "$business"})
log.debug(secLevelGv)

if (secLevelGv) {
log.debug ("Set ${issue.getKey()} to $business")
issue.setSecurityLevel (secLevelGv)
issue.store()
}

}

Now I want to copy first value to a text custom field and secend value to security level.

Could you please modify above script to solve my problem ?

1 answer

Any Help ??

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Tuesday in Marketplace Apps

If you’re an Atlassian app developer, you’ll want to know about Atlas Camp!

This September 6-7, hundreds of Atlassian App developers will flock to Barcelona Spain to build skills, discover product roadmaps, meet face-to-face with the Atlassian team, and learn how to extend t...

116 views 0 4
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you