Below is my code using in behaviour script- not working
Requirement: Auto-set Assignee based on cascade field select
import com.atlassian.jira.component.ComponentAccessor
def formhddmo = getFieldByName("cascadefield")
def assigneeField = getFieldById("assignee")
def formassign = getFieldByName("assignee")
//log.debug("----------------> " + formhddmo.getValue())
//log.debug("----------------> " + formhddimos.getValue())
String userName="kiran.p@xxx.com";
List<String> listString = formhddmo.getValue() as List<String>
def parentValue = listString.get(0)
switch(parentValue){
case "Dfgd ACC ART": userName = "jay.asdfsd@xxx.com";break;
case "HDdfgdD Infrastructure ART": userName = "Bryan.asdfsd@xxx.com";break;
case "Dfgsdf Command Flow ART": userName = "Pawan.asfasd@xxx.com";break;
case "Power and Performance": userName = "ajhsdg.Begum@xxx.com";break;
case "FWsdgdTest & Val": userName = "Alexander.Peladtt@xxx.com";break;
case "Sdfgsdfg Fmwre":
switch(formhddimos.getValue()){
case "zdsfgds": userName = "Adam.asdfsd@xxx.com";break;
case "Custosadfmer Enablement": userName = "benjamin.lundd@xxx.com";break;
case "Architecture": userName = "robert.medyer@xxx.com";break;
}
case "Rding Subsystems":
switch(formhddimos.getValue()){
case "Dfgsdfg Integration": userName = "takanori.asdfasd@xxx.com";break;
case "Elec FW": userName = "timothy.schmdalz@xxx.com";break;
}
}
// set Assignee
getFieldById(ASSIGNEE).setFormValue(userName)
Hi @Kiranped
Have you tried the username instead of the email.
For example, assuming "jay.asdfsd@xxx.com" email is "jay" username.
case "Dfgd ACC ART": userName = "jay";break;
Ok.
Do you have this import in your code?
import static com.atlassian.jira.issue.IssueFieldConstants.ASSIGNEE
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the reply.
Yes, I have.
My Jira version is 8.5.3, it's strange to even the below snippet not working
def assigneeField = getFieldById("assignee")
String userName="kiran.p@xxx.com"
assigneeField.setFormValue(userName)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This exact code works for me:
import com.atlassian.jira.componentAccessor
import static com.atlassian.jira.issue.IssueFieldConstants.ASSIGNEE
def username = "XXXX";
getFieldById(ASSIGNEE).setFormValue(username)
Can you try it with your username ?
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.