My Jira was upgraded from 7.13.x to 8.5.x
// below post-function if loop returns false in 7.13.x
if(issue.assignee){} => false
// Post Jira upgrade, below post-function if loop returns true in 8.5.x
if(issue.assignee){} => true
on both versions, create screen assignee field is 'automatic'.
I have a post-function to update assignee when unassigned based on few field selection.
Hi @Kiranped
You mentioned:-
I have a post-function to update assignee when unassigned based on few field selection.
Is this post-function working or not?
Could you please share the current post-function code that you are using?
Thank you and Kind Regards,
Ram
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.customfields.option.Option
import com.atlassian.jira.issue.customfields.option.Options
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.fields.config.FieldConfig
import com.atlassian.jira.component.ComponentAccessor
CustomFieldManager cfManager = ComponentAccessor.getCustomFieldManager()
def cfProgram = "customfield_18940"
def cfLocation = "customfield_23202"
def cfPlatform = "customfield_23203"
CustomField program = cfManager.getCustomFieldObject(cfProgram)
CustomField location = cfManager.getCustomFieldObject(cfLocation)
CustomField platform = cfManager.getCustomFieldObject(cfPlatform)
def programval = (String)issue.getCustomFieldValue(program)
def locationval = (String)issue.getCustomFieldValue(location)
def platformval = (String)issue.getCustomFieldValue(platform)
if(!issue.assignee){ // even though Asignee is not assigned as shown below - returning F
if(programval in ["Crex"] && locationval.contains("Prototyping")){
setAssigneeFunction( "1000272218")
}else if(programval in ["Optimus"] && locationval.contains("Prototyping")){
if(platformval == "HAPS70"){
setAssigneeFunction( "1000265841")
}else if(platformval in ["Palladium", "Protium"]){
setAssigneeFunction( "7329167")
}
}else if(programval in ["FW Unification"] && locationval.contains("Prototyping")){
setAssigneeFunction( "1000270976")
}else if(programval in ["General Lab"]){
if(locationval in ["Milpitas - Prototyping Lab"])
setAssigneeFunction( "1000255593")
else if(locationval in ["Bangalore - Prototyping Lab"])
setAssigneeFunction( "1000272218")
else if(locationval in ["Longmont - Prototyping Lab","Other - Prototyping Lab"])
setAssigneeFunction( "1000208616")
}else (programval in ["Heera"] && locationval.contains("Prototyping")){
setAssigneeFunction( "1000265841")
} }
def setAssigneeFunction(String username){
def userManager = ComponentAccessor.getUserManager()
def user = userManager.getUserByName(username)
issue.setAssignee(user)
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Kiranped,
For your requirement, you should try something like this:-
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.MutableIssue
def mutableIssue = issue as MutableIssue
def customFieldManager = ComponentAccessor.customFieldManager
def issueManager = ComponentAccessor.issueManager
def userManager = ComponentAccessor.userManager
def processType = customFieldManager.getCustomFieldObjectsByName('Process Type').first()
def processTypeValue = processType.getValue(mutableIssue).toString()
def assignee
if (processTypeValue == 'Solution Design') {
assignee = userManager.getUserByName('ram')
} else if (processTypeValue == 'Development') {
assignee = userManager.getUserByName('max')
} else if (processTypeValue == 'QA') {
assignee = userManager.getUserByName('admin')
}
mutableIssue.setAssignee(assignee)
issueManager.updateIssue(assignee,mutableIssue, EventDispatchOption.DO_NOT_DISPATCH,false)
Please note, the sample working code above is not 100% exact to your environment. Hence, you will need to make the required modifications.
The main thing missing in your code is this:-
issueManager.updateIssue(assignee,mutableIssue, EventDispatchOption.DO_NOT_DISPATCH,false)
You need to include this to ensure that the update to the issue via the post-function is triggered.
Below is a print screen of the Post-Function configuration:-
Below are a few test print screens:-
1. If the Product type selected is Solution Design, as shown below:-
The Assignee is set to Ram Kumar as shown in the image below:-
2. If the Product type selected is Development, as shown below:-
The Assignee is set to Max Peterson as shown in the image below:-
3. If the Product type selected is QA, as shown below:-
The Assignee is set to Admin as shown in the image below:-
I hope this helps to answer your question. :)
Thank you and Kind Regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Ram Kumar Aravindakshan _Adaptavist_ ,
Thanks for your response.
The requirement here is:
if(issue.assignee) // it should return true only if the assignee field is updated on create screen OR it should return False in-case assignee field is not updated or left 'automatic'
The problem is: issue.assignee // returning true in all case
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Kiranped
If you want to check whether the issue assignee has been selected on the Create screen, you need to use the Behaviour instead of the Post-Function to validate it.
Thank you and Kind Regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.