Please forgive me if this is a complete mess this is the first time I have tried to use a Behavior-I have two custom fields - Contract Type and Department I want to set the Security Level based off a combination of both of these when ever the issue is updated (Mainly when the Department or Contract Type are updated)
I created a Behavior for the Workflow OCR-Contracts
Then added the Field: SecurityLevle and (Server Side Script) I added the following code: that give me a red x next to every line that says Issue.setSecurityLevleID with "The variable issue is undeclared"
import com.atlassian.jira.ComponentManager import com.atlassian.jira.ManagerFactory import com.atlassian.jira.issue.security.IssueSecurityLevelManager import com.atlassian.jira.issue.security.IssueSecuritySchemeManager import com.atlassian.jira.issue.IssueImpl import org.apache.log4j.Category import com.atlassian.jira.issue.MutableIssue; import org.ofbiz.core.entity.GenericValue import com.atlassian.jira.ComponentManager; import com.atlassian.jira.bc.project.component.ProjectComponent; import com.atlassian.jira.bc.project.component.ProjectComponentManager; import com.atlassian.jira.issue.Issue; import com.atlassian.jira.issue.IssueFactory; ComponentManager componentManager = ComponentManager.getInstance() ; def ContactType = getCustomFieldValue("Contract Type") def Department = getCustomFieldValue("Department") if(ContactType && Department) { if( (ContactType == "OCR Clickthrough Agreement") && (Department == "Business to Business") ) issue.setSecurityLevelId(10303) } else if( (ContactType == "Advertising Agreement") && (Department == "Business to Business") ) { issue.setSecurityLevelId(10304) } else if( (ContactType == "Data Use Agreement") && (Department == "Business to Business") ) { issue.setSecurityLevelId(10304) } else if( (ContactType == "Clickthrough/Electronic Agreement") && (Department == "Business to Business") ) { issue.setSecurityLevelId(10304) } else if( (ContactType == "Facilities Agreement") && (Department == "Business to Business") ) { issue.setSecurityLevelId(10304) } else if( (ContactType == "Instructor Agreement") && (Department == "Business to Business") ) { issue.setSecurityLevelId(10304) } else if( (ContactType == "License Agreement") && (Department == "Business to Business") ) { issue.setSecurityLevelId(10304) } else if( (ContactType == "Memorandum of Agreement/Understanding") && (Department == "Business to Business") ) { issue.setSecurityLevelId(10304) } else if( (ContactType == "Non-disclosure Agreement") && (Department == "Business to Business") ) { issue.setSecurityLevelId(10304) } else if( (ContactType == "Other Agreement") && (Department == "Business to Business") ) { issue.setSecurityLevelId(10304) } else if( (ContactType == "Rental Agreement") && (Department == "Business to Business") ) { issue.setSecurityLevelId(10304) } else if( (ContactType == "Services Agreement") && (Department == "Business to Business") ) { issue.setSecurityLevelId(10304) } else if( (ContactType == "Shipping Agreement") && (Department == "Business to Business") ) { issue.setSecurityLevelId(10304) } else if( (ContactType == "Speaker Agreement") && (Department == "Business to Business") ) { issue.setSecurityLevelId(10304) } else if( (ContactType == "Software and/or Software-as-a-Service Agreement") && (Department == "Business to Business") ) { issue.setSecurityLevelId(10304) } else if( (ContactType == "Vendor Registration") && (Department == "Business to Business") ) { issue.setSecurityLevelId(10304) }
I finally got this working: Added code to both Contract Type and Department so it would update if they updated one or the other or both.
Code for Department
import com.atlassian.jira.issue.fields.CustomField import com.atlassian.jira.issue.CustomFieldManager import com.atlassian.jira.issue.Issue import com.onresolve.jira.groovy.user.FieldBehaviours import com.onresolve.jira.groovy.user.FormField import com.atlassian.jira.component.ComponentAccessor def departmentValue = getFieldById(getFieldChanged()).value def contractTypeValue = getFieldById("customfield_12576").value log.debug ("contractTypeValue: ${contractTypeValue}") log.debug ("departmentValue: ${departmentValue}") log.debug ("contractTypeValue type: ${contractTypeValue.class.name}") log.debug ("departmentValue type: ${departmentValue.class.name}") if(contractTypeValue.toString().contains("OCR Clickthrough Agreement") && (departmentValue.toString().contains("Business to Business"))) { def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10303 as Long) }else if(contractTypeValue.toString().contains("OCR Clickthrough Agreement") && (departmentValue.toString().contains("Center for Online Innovation in Learning"))) { def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10303 as Long) } else if(contractTypeValue.toString().contains("OCR Clickthrough Agreement") && (departmentValue.toString().contains("Conferences"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10303 as Long) } else if(contractTypeValue.toString().contains("OCR Clickthrough Agreement") && (departmentValue.toString().contains("Continuing Education"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10303 as Long) } else if(contractTypeValue.toString().contains("OCR Clickthrough Agreement") && (departmentValue.toString().contains("Conferences"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10303 as Long) } else if(contractTypeValue.toString().contains("OCR Clickthrough Agreement") && (departmentValue.toString().contains("Corporate Learning"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10303 as Long) } else if(contractTypeValue.toString().contains("OCR Clickthrough Agreement") && (departmentValue.toString().contains("Development"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10303 as Long) } else if(contractTypeValue.toString().contains("OCR Clickthrough Agreement") && (departmentValue.toString().contains("Human Resources"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10303 as Long) } else if(contractTypeValue.toString().contains("OCR Clickthrough Agreement") && (departmentValue.toString().contains("JASI"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10303 as Long) } else if(contractTypeValue.toString().contains("OCR Clickthrough Agreement") && (departmentValue.toString().contains("Learning Design"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10303 as Long) } else if(contractTypeValue.toString().contains("OCR Clickthrough Agreement") && (departmentValue.toString().contains("Marketing"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10303 as Long) } else if(contractTypeValue.toString().contains("OCR Clickthrough Agreement") && (departmentValue.toString().contains("Office of Information Technology"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10303 as Long) } else if(contractTypeValue.toString().contains("OCR Clickthrough Agreement") && (departmentValue.toString().contains("Non-Credit Registration"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10303 as Long) } else if(contractTypeValue.toString().contains("OCR Clickthrough Agreement") && (departmentValue.toString().contains("OLLI"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10303 as Long) } else if(contractTypeValue.toString().contains("OCR Clickthrough Agreement") && (departmentValue.toString().contains("Operations"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10303 as Long) } else if(contractTypeValue.toString().contains("OCR Clickthrough Agreement") && (departmentValue.toString().contains("PSPM"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10306 as Long) } else if(contractTypeValue.toString().contains("Advertising Agreement") && (departmentValue.toString().contains("PSPM"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10305 as Long) } else if(contractTypeValue.toString().contains("Data Use Agreement") && (departmentValue.toString().contains("PSPM"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10305 as Long) } else if(contractTypeValue.toString().contains("Clickthrough/Electronic Agreement") && (departmentValue.toString().contains("PSPM"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10305 as Long) } else if(contractTypeValue.toString().contains("Facilities Agreement") && (departmentValue.toString().contains("PSPM"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10305 as Long) } else if(contractTypeValue.toString().contains("Instructor Agreement") && (departmentValue.toString().contains("PSPM"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10305 as Long) } else if(contractTypeValue.toString().contains("License Agreement") && (departmentValue.toString().contains("PSPM"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10305 as Long) } else if(contractTypeValue.toString().contains("Memorandum of Agreement/Understanding") && (departmentValue.toString().contains("PSPM"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10305 as Long) } else if(contractTypeValue.toString().contains("Non-disclosure Agreement") && (departmentValue.toString().contains("PSPM"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10305 as Long) } else if(contractTypeValue.toString().contains("Other Agreement") && (departmentValue.toString().contains("PSPM"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10305 as Long) } else if(contractTypeValue.toString().contains("Rental Agreement") && (departmentValue.toString().contains("PSPM"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10305 as Long) } else if(contractTypeValue.toString().contains("Services Agreement") && (departmentValue.toString().contains("PSPM"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10305 as Long) } else if(contractTypeValue.toString().contains("Shipping Agreement") && (departmentValue.toString().contains("PSPM"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10305 as Long) } else if(contractTypeValue.toString().contains("Speaker Agreement") && (departmentValue.toString().contains("PSPM"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10305 as Long) } else if(contractTypeValue.toString().contains("Software and/or Software-as-a-Service Agreement") && (departmentValue.toString().contains("PSPM"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10305 as Long) } else if(contractTypeValue.toString().contains("Vendor Registration") && (departmentValue.toString().contains("PSPM"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10305 as Long) } else if(contractTypeValue.toString().contains("OCR Clickthrough Agreement") && (departmentValue.toString().contains("Penn Tap"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10303 as Long) } else if(contractTypeValue.toString().contains("OCR Clickthrough Agreement") && (departmentValue.toString().contains("SBDC"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10303 as Long) } else if(contractTypeValue.toString().contains("OCR Clickthrough Agreement") && (departmentValue.toString().contains("Shavers Creek"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10303 as Long) } else if(contractTypeValue.toString().contains("OCR Clickthrough Agreement") && (departmentValue.toString().contains("Strategic Partnerships"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10303 as Long) } else if(contractTypeValue.toString().contains("OCR Clickthrough Agreement") && (departmentValue.toString().contains("World Campus"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10303 as Long) } else if(contractTypeValue.toString().contains("OCR Clickthrough Agreement") && (departmentValue.toString().contains("Other"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10303 as Long) } else { def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10304) }
:
Code for Contract Type:
import com.atlassian.jira.issue.fields.CustomField import com.atlassian.jira.issue.CustomFieldManager import com.atlassian.jira.issue.Issue import com.onresolve.jira.groovy.user.FieldBehaviours import com.onresolve.jira.groovy.user.FormField import com.atlassian.jira.component.ComponentAccessor def contractTypeValue = getFieldById(getFieldChanged()).value def departmentValue = getFieldById("customfield_12574").value log.debug ("contractTypeValue: ${contractTypeValue}") log.debug ("departmentValue: ${departmentValue}") log.debug ("contractTypeValue type: ${contractTypeValue.class.name}") log.debug ("departmentValue type: ${departmentValue.class.name}") if(contractTypeValue.toString().contains("OCR Clickthrough Agreement") && (departmentValue.toString().contains("Business to Business"))) { def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10303 as Long) }else if(contractTypeValue.toString().contains("OCR Clickthrough Agreement") && (departmentValue.toString().contains("Center for Online Innovation in Learning"))) { def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10303 as Long) } else if(contractTypeValue.toString().contains("OCR Clickthrough Agreement") && (departmentValue.toString().contains("Conferences"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10303 as Long) } else if(contractTypeValue.toString().contains("OCR Clickthrough Agreement") && (departmentValue.toString().contains("Continuing Education"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10303 as Long) } else if(contractTypeValue.toString().contains("OCR Clickthrough Agreement") && (departmentValue.toString().contains("Conferences"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10303 as Long) } else if(contractTypeValue.toString().contains("OCR Clickthrough Agreement") && (departmentValue.toString().contains("Corporate Learning"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10303 as Long) } else if(contractTypeValue.toString().contains("OCR Clickthrough Agreement") && (departmentValue.toString().contains("Development"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10303 as Long) } else if(contractTypeValue.toString().contains("OCR Clickthrough Agreement") && (departmentValue.toString().contains("Human Resources"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10303 as Long) } else if(contractTypeValue.toString().contains("OCR Clickthrough Agreement") && (departmentValue.toString().contains("JASI"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10303 as Long) } else if(contractTypeValue.toString().contains("OCR Clickthrough Agreement") && (departmentValue.toString().contains("Learning Design"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10303 as Long) } else if(contractTypeValue.toString().contains("OCR Clickthrough Agreement") && (departmentValue.toString().contains("Marketing"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10303 as Long) } else if(contractTypeValue.toString().contains("OCR Clickthrough Agreement") && (departmentValue.toString().contains("Office of Information Technology"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10303 as Long) } else if(contractTypeValue.toString().contains("OCR Clickthrough Agreement") && (departmentValue.toString().contains("Non-Credit Registration"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10303 as Long) } else if(contractTypeValue.toString().contains("OCR Clickthrough Agreement") && (departmentValue.toString().contains("OLLI"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10303 as Long) } else if(contractTypeValue.toString().contains("OCR Clickthrough Agreement") && (departmentValue.toString().contains("Operations"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10303 as Long) } else if(contractTypeValue.toString().contains("OCR Clickthrough Agreement") && (departmentValue.toString().contains("PSPM"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10306 as Long) } else if(contractTypeValue.toString().contains("Advertising Agreement") && (departmentValue.toString().contains("PSPM"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10305 as Long) } else if(contractTypeValue.toString().contains("Data Use Agreement") && (departmentValue.toString().contains("PSPM"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10305 as Long) } else if(contractTypeValue.toString().contains("Clickthrough/Electronic Agreement") && (departmentValue.toString().contains("PSPM"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10305 as Long) } else if(contractTypeValue.toString().contains("Facilities Agreement") && (departmentValue.toString().contains("PSPM"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10305 as Long) } else if(contractTypeValue.toString().contains("Instructor Agreement") && (departmentValue.toString().contains("PSPM"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10305 as Long) } else if(contractTypeValue.toString().contains("License Agreement") && (departmentValue.toString().contains("PSPM"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10305 as Long) } else if(contractTypeValue.toString().contains("Memorandum of Agreement/Understanding") && (departmentValue.toString().contains("PSPM"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10305 as Long) } else if(contractTypeValue.toString().contains("Non-disclosure Agreement") && (departmentValue.toString().contains("PSPM"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10305 as Long) } else if(contractTypeValue.toString().contains("Other Agreement") && (departmentValue.toString().contains("PSPM"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10305 as Long) } else if(contractTypeValue.toString().contains("Rental Agreement") && (departmentValue.toString().contains("PSPM"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10305 as Long) } else if(contractTypeValue.toString().contains("Services Agreement") && (departmentValue.toString().contains("PSPM"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10305 as Long) } else if(contractTypeValue.toString().contains("Shipping Agreement") && (departmentValue.toString().contains("PSPM"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10305 as Long) } else if(contractTypeValue.toString().contains("Speaker Agreement") && (departmentValue.toString().contains("PSPM"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10305 as Long) } else if(contractTypeValue.toString().contains("Software and/or Software-as-a-Service Agreement") && (departmentValue.toString().contains("PSPM"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10305 as Long) } else if(contractTypeValue.toString().contains("Vendor Registration") && (departmentValue.toString().contains("PSPM"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10305 as Long) } else if(contractTypeValue.toString().contains("OCR Clickthrough Agreement") && (departmentValue.toString().contains("Penn Tap"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10303 as Long) } else if(contractTypeValue.toString().contains("OCR Clickthrough Agreement") && (departmentValue.toString().contains("SBDC"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10303 as Long) } else if(contractTypeValue.toString().contains("OCR Clickthrough Agreement") && (departmentValue.toString().contains("Shavers Creek"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10303 as Long) } else if(contractTypeValue.toString().contains("OCR Clickthrough Agreement") && (departmentValue.toString().contains("Strategic Partnerships"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10303 as Long) } else if(contractTypeValue.toString().contains("OCR Clickthrough Agreement") && (departmentValue.toString().contains("World Campus"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10303 as Long) } else if(contractTypeValue.toString().contains("OCR Clickthrough Agreement") && (departmentValue.toString().contains("Other"))){ def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10303 as Long) } else { def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10304) }
Hi Michelle,
So your script looks more like a custom post function than a behaviour. So in a behaviour you should have something like
def contractTypeValue = getFieldByName("Contract Type").getValue() def departmentValue = getFieldByName("Department").getValue() //your conditions here... //get the security field def securityLvlId = getFieldById ("security") //set a security level using it's id securityLvlId.setFormValue(10304 as Long)
Note: (even though it seems you already know it ) you can get the id of the security lvl by browsing to your issue security scheme, then, if your browser is set to show the status bar (window bottom), put the cursor on the "delete" link and you will find an URL with something like this at the end: levelId=10304&schemeId=10010 - the "levelID" is the Security Level ID.
There is also a built in function Set Issue Security where you can easily set security level to issues depending on conditions. But I do not know your exact requirements.
Apologies for the late response. Please let me know if you need further assistance.
regards,
Thanos
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
So I updated my code and put it in the Security Level and it didn't seem to work so I put it in Department then Contract Type even as a Initialiser and it still does not seem to be updating the field when I edit change the Department or the Contract Type.
def contractTypeValue = getFieldByName("Contract Type").getValue() def departmentValue = getFieldByName("Department").getValue() if( (contractTypeValue == "OCR Clickthrough Agreement") && (departmentValue == "Business to Business") ) { def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10303) } else if( (contractTypeValue == "Advertising Agreement") && (departmentValue == "Business to Business") ) { def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10304) } else if( (contractTypeValue == "Data Use Agreement") && (departmentValue == "Business to Business") ) { def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10304) } else if( (contractTypeValue == "Clickthrough/Electronic Agreement") && (departmentValue == "Business to Business") ) { def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10304) } else if( (contractTypeValue == "Facilities Agreement") && (departmentValue == "Business to Business") ) { def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10304) } else if( (contractTypeValue == "Instructor Agreement") && (departmentValue == "Business to Business") ) { def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10304) } else if( (contractTypeValue == "License Agreement") && (departmentValue == "Business to Business") ) { def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10304) } else if( (contractTypeValue == "Memorandum of Agreement/Understanding") && (departmentValue == "Business to Business") ) { def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10304) } else if( (contractTypeValue == "Non-disclosure Agreement") && (departmentValue == "Business to Business") ) { def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10304) } else if( (contractTypeValue == "Other Agreement") && (departmentValue == "Business to Business") ) { def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10304) } else if( (contractTypeValue == "Rental Agreement") && (departmentValue == "Business to Business") ) { def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10304) } else if( (contractTypeValue == "Services Agreement") && (departmentValue == "Business to Business") ) { def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10304) } else if( (contractTypeValue == "Shipping Agreement") && (departmentValue == "Business to Business") ) { def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10304) } else if( (contractTypeValue == "Speaker Agreement") && (departmentValue == "Business to Business") ) { def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10304) } else if( (contractTypeValue == "Software and/or Software-as-a-Service Agreement") && (departmentValue == "Business to Business") ) { def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10304) } else if( (contractTypeValue == "Vendor Registration") && (departmentValue == "Business to Business") ) { def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10304) } else { def securityLvlId = getFieldById ("security") securityLvlId.setFormValue(10302) }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Michelle,
I would propose you to "build it in steps". For example I would begin with an initialiser and the script without the conditions - to make sure that the security lvl id is fine. For example
//get the security field def securityLvlId = getFieldById ("security") //set a security level using it's id securityLvlId.setFormValue(10304 as Long)
and see if this works. And then try adding the conditions, by making sure that the conditions return an expected value (in the example) for example
def contractTypeValue = getFieldByName("Contract Type").getValue() def departmentValue = getFieldByName("Department").getValue() log.debug ("contractTypeValue: ${contractTypeValue}") log.debug ("departmentValue: ${departmentValue}")
regards
Thanos
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
So
I have tried this several times however it does not seem to be getting the value of the Department or Contract Type (note these two are select lists) not sure if that makes a difference.
2016-08-23 11:31:22,375 http-nio-80-exec-1 DEBUG mrl19 691x4523x2 1qki83l 146.186.206.60 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validators.json [c.o.j.groovy.user.FieldBehaviours] contractTypeValue: null 2016-08-23 11:31:22,391 http-nio-80-exec-1 DEBUG mrl19 691x4523x2 1qki83l 146.186.206.60 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validators.json [c.o.j.groovy.user.FieldBehaviours] departmentValue: null 2016-08-23 11:31:48,032 http-nio-80-exec-6 DEBUG mrl19 691x4528x2 1qki83l 146.186.206.60 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validators.json [c.o.j.groovy.user.FieldBehaviours] contractTypeValue: null 2016-08-23 11:31:48,032 http-nio-80-exec-6 DEBUG mrl19 691x4528x2 1qki83l 146.186.206.60 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validators.json [c.o.j.groovy.user.FieldBehaviours] departmentValue: null 2016-08-23 11:31:50,829 http-nio-80-exec-25 DEBUG mrl19 691x4533x1 1qki83l 146.186.206.60 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validators.json [c.o.j.groovy.user.FieldBehaviours] contractTypeValue: null 2016-08-23 11:31:50,829 http-nio-80-exec-25 DEBUG mrl19 691x4533x1 1qki83l 146.186.206.60 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validators.json [c.o.j.groovy.user.FieldBehaviours] departmentValue: null 2016-08-23 11:32:04,719 http-nio-80-exec-9 DEBUG mrl19 692x4538x1 1qki83l 146.186.206.60 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validators.json [c.o.j.groovy.user.FieldBehaviours] contractTypeValue: null 2016-08-23 11:32:04,719 http-nio-80-exec-9 DEBUG mrl19 692x4538x1 1qki83l 146.186.206.60 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validators.json [c.o.j.groovy.user.FieldBehaviours] departmentValue: null 2016-08-23 11:41:53,981 http-nio-80-exec-19 DEBUG mrl19 701x4628x2 1qki83l 146.186.206.60 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validators.json [c.o.j.groovy.user.FieldBehaviours] contractTypeValue: null 2016-08-23 11:41:53,981 http-nio-80-exec-19 DEBUG mrl19 701x4628x2 1qki83l 146.186.206.60 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validators.json [c.o.j.groovy.user.FieldBehaviours] departmentValue: null 2016-08-23 11:41:57,450 http-nio-80-exec-17 DEBUG mrl19 701x4639x1 1qki83l 146.186.206.60 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validators.json [c.o.j.groovy.user.FieldBehaviours] contractTypeValue: null 2016-08-23 11:41:57,450 http-nio-80-exec-17 DEBUG mrl19 701x4639x1 1qki83l 146.186.206.60 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validators.json [c.o.j.groovy.user.FieldBehaviours] departmentValue: null 2016-08-23 11:42:01,653 http-nio-80-exec-2 DEBUG mrl19 702x4646x2 1qki83l 146.186.206.60 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validators.json [c.o.j.groovy.user.FieldBehaviours] contractTypeValue: null 2016-08-23 11:42:01,653 http-nio-80-exec-2 DEBUG mrl19 702x4646x2 1qki83l 146.186.206.60 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validators.json [c.o.j.groovy.user.FieldBehaviours] departmentValue: null 2016-08-23 11:50:50,277 http-nio-80-exec-20 DEBUG mrl19 710x4679x2 1qki83l 146.186.206.60 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validators.json [c.o.j.groovy.user.FieldBehaviours] contractTypeValue: null 2016-08-23 11:50:50,277 http-nio-80-exec-20 DEBUG mrl19 710x4679x2 1qki83l 146.186.206.60 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validators.json [c.o.j.groovy.user.FieldBehaviours] departmentValue: null 2016-08-23 11:50:55,496 http-nio-80-exec-12 DEBUG mrl19 710x4684x2 1qki83l 146.186.206.60 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validators.json [c.o.j.groovy.user.FieldBehaviours] contractTypeValue: null 2016-08-23 11:50:55,496 http-nio-80-exec-12 DEBUG mrl19 710x4684x2 1qki83l 146.186.206.60 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validators.json [c.o.j.groovy.user.FieldBehaviours] departmentValue: null
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.