User Tools

Site Tools


conditions

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
conditions [2017/06/15 15:03]
pawel
conditions [2018/04/13 10:39] (current)
root Added new condition
Line 9: Line 9:
 </code> </code>
  
 +=== Only if Version 2.0 not in Fix Version field ===
 +
 +<code java>
 +!("Version 2.0" in issue.fixVersions*.name)
 +</code>
 +
 +=== Only return true if we have "Awaiting Approval" in field Approval Stats and therefore display transition ===
 +
 +<code java>
 +import com.atlassian.jira.component.ComponentAccessor
 +
 +//Define Custom Field Manager
 +def cfm = ComponentAccessor.getCustomFieldManager()
 +//get field object
 +def cfApprovalStatus = cfm.getCustomFieldObjectByName("Approval Status")
 +def cfApprovalStatusValue = issue.getCustomFieldValue(cfApprovalStatus)
 +//check if the field is equal to Awaiting Approval
 +if (cfApprovalStatusValue == "Awaiting Approval"){
 +    //Returned true in comparison
 +    return true
 +}
 +</code>
 +
 +=== Only allow transition if none of the values in custom fields are "Awaiting Approval" ===
 +
 +<code java>
 +import com.atlassian.jira.component.ComponentAccessor
 +
 +//Define cfm
 +def cfm = ComponentAccessor.getCustomFieldManager()
 +//get field object
 +def cfFirstApprovalStatus = cfm.getCustomFieldObjectByName("First Approval Status")
 +def cfFirstApprovalStatusValue = issue.getCustomFieldValue(cfFirstApprovalStatus)
 +def cfSecondApprovalStatus = cfm.getCustomFieldObjectByName("Second Approval Status")
 +def cfSecondApprovalStatusValue = issue.getCustomFieldValue(cfSecondApprovalStatus)
 +
 +if ((cfFirstApprovalStatusValue != "Awaiting Approval")&&(cfSecondApprovalStatusValue != "Awaiting Approval"){
 +    //Returned true in comparison
 +    return true
 +}
 +</code>
 +
 +=== Allow only if user is member of role "Developers" in project OR "My Field" has value of "Field Value" ===
 +<code java>
 +import com.atlassian.jira.component.ComponentAccessor 
 +
 +def selectedMyField = cfValues['My Field'].toString()
 +
 +
 +def userUtil = ComponentAccessor.getUserUtil()
 +
 +    isUserMemberOfRole("Developers") || selectedMyField.equals("Field Value")
 +
 +
 +</code>
conditions.1497553393.txt.gz · Last modified: 2017/06/15 15:03 by pawel