You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
hello team ,
Find my code for requirement :
Assessed branch : Select list field A
Relevance : Select list field B
Commit_ID : Wiki render field ( with table values )
Based on selection of A and B - User must fill the Table value in ( Commit ID / LABEL) for specific hard coded Assessed branch table value .
Code is working perfectly . However , In wiki render field ( There is 2 option available as
VISUAL and TEXT .
In Visual - Deletion on table is not possible and user can able to provide / Edit values and make the movement to next transition .
In Text - Deletion of table is possible and it makes the user bypass the specific transition . therefore , As similar to visual - deletion of tables thru TEXT option must be restricted ..
NEED HELP for adding the restriction script in my below script
Wiki render field ( Commit_ID ) must work for value provide / edit and user must not able to delete the table .
Working code :
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.roles.ProjectRoleManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.config.StatusManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.roles.ProjectRoleManager
// Get the fields by its name
def Assessed = getFieldByName("Assessed Branch")
def Commit_ID_field_values = getFieldByName("Commit_ID")
def Relevance = getFieldByName("Relevance")
// Get the field values
def branch = Assessed.getValue() as String[]
def relevance = Relevance.getValue() as String[]
String outcome = Commit_ID_field_values.getValue()
Commit_ID_field_values.clearError() // Clear the error message before the validation
//Get the status values
def currentStatus = underlyingIssue.getStatus().name
def validStatusList = ["Committed", "Rejected"]
if(currentStatus in validStatusList){
if (getActionName() == "Accomplish Fix" || getDestinationStepName() == "Fixed") {
def BlackArrow = ["18.1", "21.2", "Feature branch"]
def PinkArrow = ["18.1", "Feature branch"]
def BlueArrow = ["18.1", "Feature branch"]
//def YellowArrow = ["22.1", "Feature branch"]
def LilacArrow = ["21.4", "22.1", "Feature branch"]
def VividGreenArrow = ["21.2", "Feature branch"]
//def RedArrow = ["22.2","Feature branch"]
def GreyArrow = ["21.3", "22.2", "Feature branch"]
def Requiredbranchs = ["Feature branch"]
for (String rel in relevance) {
if (rel == "Scope2.1 Nissan" || rel == "Scope 2.0 ROW" || rel == "Scope2 P32R"){
if (branch != [null])
{branch.each{Requiredbranchs.add(it)?: (Requiredbranchs.contains(it))}
}
if (branch.contains("18.1")){
BlackArrow.each{(Requiredbranchs.contains(it))?: Requiredbranchs.add(it)}
}
}
else if (rel == "Scope2.1 Renault Portrait" || rel == "Scope2.1 Renault Landscape"){
if (branch != [null] && branch.contains("18.1") || !branch.contains("18.1")){ // If Assessed Branch is not empty and not containing "18.1"
branch.each{Requiredbranchs.add(it) ?: (Requiredbranchs.contains(it))} // Add Assessed Branch value to the Requiredbranchs list
}
else{
PinkArrow.each{(Requiredbranchs.contains(it))?: Requiredbranchs.add(it)} // Add BlueArrow values to the Requiredbranchs list
}
}
else if (rel == "P-IVI" ) {
if (branch != [null] && branch.contains("18.1") || !branch.contains("18.1")){
branch.each{Requiredbranchs.add(it) ?: (Requiredbranchs.contains(it))}
}
else{
BlueArrow.each{(Requiredbranchs.contains(it))?: Requiredbranchs.add(it)}
}
}
else if (rel == "Nissan ST3.x" || rel == "MMC ST3.x") {
if (branch != [null] && branch.contains("21.2") || !branch.contains("21.2")){
branch.each{Requiredbranchs.add(it) ?: (Requiredbranchs.contains(it))}
}
else{
VividGreenArrow.each{(Requiredbranchs.contains(it))?: Requiredbranchs.add(it)}
}
}
else if (rel == "Nissan AIVI2-S1" || rel == "PIVI ST3.1"){
if (branch != [null])
{branch.each{Requiredbranchs.add(it) ?: (Requiredbranchs.contains(it))}
}
if (branch.contains("21.4")){
LilacArrow.each{(Requiredbranchs.contains(it))?: Requiredbranchs.add(it)}
}
}
else if (rel == "Scope3.5 Renault Portrait" || rel == "Scope3.5 Renault Landscape"){
if (branch != [null])
{branch.each{Requiredbranchs.add(it) ?: (Requiredbranchs.contains(it))}
}
if (branch.contains("21.3")){
GreyArrow.each{(Requiredbranchs.contains(it))?: Requiredbranchs.add(it)}
}
}
else{
branch.each{Requiredbranchs.add(it)?: (Requiredbranchs.contains(it))}
}
def regex = /^.[a-zA-Z0-9!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?].*$/
if(outcome){
outcome.eachLine{
// ======================= Do the validation here
if(it != "||Assessed Branch||Commit ID/Label||"){ // Skip the table header
String firstcoloum = it.trim().split("\\|")[1] // Get the value from the first column
if(Requiredbranchs.contains(firstcoloum)){
boolean Secondcoloum = it.trim().split("\\|")[2] ==~ regex
if(!Secondcoloum){
Commit_ID_field_values.setError("You must fill the Commit ID/Label Value for " + Requiredbranchs.join(", "))
}
}
// else {Commit_ID_field_values.setError("Missing Commit ID details for the required Assessed Branch " + Requiredbranchs.join(", "))}
}
}
}
// else {Commit_ID_field_values.setError("Missing Commit ID details for the required Assessed Branch " + Requiredbranchs.join(", "))}
}
}
}