Forums

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

Assign variable into a custom field base on component

Shah Baloch
Contributor
July 27, 2020

There are multiple components in the project, tickets get assign to users base on the component, for example if user select component "Product" then ticket gets assign to product lead, whenever he change status to "Approval Need" it should get assign to a Supervisor. I can add a supervisor in Post function but there are multiple components and there is only one work flow and issue type. If add user there then all ticket assign to him which we don't want, each component has there own lead and supervisor. For example Product component go product team, Customer components ticket assign to Customer team and Supplier to supplier team.

There is two approval Supervisor, I want to create two variable user1 and user2, if user select component "Product" to create a ticket, it should assign user2 otherwise it should add user1  to customer assignee field, then I'll use that assignee field in a User define Post function in workflow, so whenever product lead change the status it should get assign to Product Supervisor, rest of the component it should do nothing or assign to user1. I am trying add following Listener script but it won't working, I know it is not correct, I don't have an idea how to make it work.

import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.scriptrunner.db.DatabaseUtil
import com.atlassian.jira.event.issue.IssueEvent
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import java.sql.Timestamp
import com.atlassian.jira.bc.project.component.ProjectComponent

def event = event as IssueEvent
def issue = event.issue
def customFieldObjects = ComponentAccessor.customFieldManager.getCustomFieldObjects(issue)
def user1 = 'abc'
def user2 = 'xyz'

def cfAsignee = customFieldObjects.findById("customField_10401")
def components = getFieldById(getFieldChanged()).getValue() as List<ProjectComponent>

if(components == 'Product') {
cfAsignee.modifiedValue(user2)

else

cfAsignee.modifiedValue(user1)

}

Thank you

 

1 answer

Suggest an answer

Log in or Sign up to answer
0 votes
Nir Haimov
Community Champion
September 4, 2021

Hi @Minh Malaterre 

Seems like the error is the field you put.

getFieldById("issuelinks-issues"), try to make sure the ID is correct or the method is correct

TAGS
AUG Leaders

Atlassian Community Events