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
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published Thursday in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas Camp   is our developer event which will take place in Barcelona, Spain  from the 6th -7th of   September . This is a great opportunity to meet other developers and get n...

260 views 0 6
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