Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Make Fields required during specific options for different workflow

Hi All

 

I have a scenario where i have a single list type Field called "Requirement Type",Which has two values Functional and Non-Functional.

 

Functional doesnt contaion any specific values, but Non Function is a tab and it will only show when requirement type is Non-Functional and it has some fields values like, Correspondence, Physical requirements etc.

My requirement is two make all the fields under functional and non-functional as required when status goes from "In Progress" to " Complete".

Previously i have added in workflow validator all the fields should be required, but now i am facing a the problem like when i have filled all the details (not Nun Functional Details)  and trying to progress from one state to another all those Non Functional fields are also saying error messages like its Required.

below i have tried the code but its not working, i have tried in Behavior and Script Validator in Workflow, but unable to do it.

 

Can anyone help me on this ? I am new to Behaviors .

Behavior Code : ----

import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.jira.groovy.user.FormField
import groovy.transform.BaseScript
import org.apache.log4j.Level ;
import org.apache.log4j.Logger ;


log.setLevel(Level.DEBUG) ;
@BaseScript FieldBehaviours fieldBehaviours

FormField dropDownList = getFieldByName("Requirement Type")
FormField condition1 = getFieldByName("Correspondence:") // Corresponde field
//FormField condition2 = getFieldById("12254")
if(dropDownList == "Non-Functional"){
condition1.setRequired(true)
}
else{
condition1.setRequired(false)
}

 

 

Script validator Code : --

import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.jira.groovy.user.FormField
import groovy.transform.BaseScript

@BaseScript FieldBehaviours fieldBehaviours
FormField condition2 = getFieldById("12254")
if(issue.getAsString("customfield_16300") == "Non-Functional"){
condition2.setRequired(true)
}else{
condition2.setRequired(false)
}

 

 

 

 

Regards

Manas

1 answer

0 votes
Leo Community Leader Jan 28, 2020

Hi @J Manas Kumar,

I would suggest Behaviour for your requirement

Remove all script validators related to this during mentioned transition

Add below behvaviour for "Requirement Type" field(in my script I made Requirement type field as mandatory one by default)

Also this behaviour will work only during mentioned transition if you use the screen only there

getFieldByName("Requirement Type").setRequired(true)

if(getFieldScreen().name == "Transition Screen"){
def value = getFieldByName("Requirement Type").getFormValue() as String
if(value == "Functional"){
//set required on all fields related to functional, example below
getFieldByName("Functional Field 1").setRequired(true)
getFieldByName("Functional Field 2").setRequired(true)
}else if(value == "Non-Functional"){
//set required on all fields related to non functional, example below
getFieldByName("Non Functional Field 1").setRequired(true)
getFieldByName("Non Functional Field 2").setRequired(true)
}
}

 

Hope this will give you some idea

 

BR,

Leo

Hi @Leo 

 

the Method getScreenField() and the Transition Screen you are saying, my question is like previously  i used to create Issues.Status == "In Progress" , for any workflow transition, here how can i add the transition, simply mentioning "In Progress" or it will auto detect that current transition,. i searched for the getScreenField() method in JIra lib.

 

Can you provide little bit more details.

 

 

Regards

Manas

Leo Community Leader Jan 28, 2020 • edited

Hi @J Manas Kumar,

This is screen name you used in the workflow to populate fields during transition like resolution screen in resolved transition

e.g: screen name is "Functional Fields update Screen". you should pass this to script

it's just to avoid behaviour script to involve in any other places like create/edit screens

hope this would give you some idea, let me know if you are not clear

 

BR,

Leo

Hi @Leo 

Got some reference what you are saying , below i have added my code for 1 specific Project screen for both edit and create. Is that correct way to define transition screen.?

and can we add statuses in place of screens? Like while create and edit screen or issue i need all the fields to be work in proper way and it should be validate in transtion workflow when it will go from "In Progress" to "Complete" Status.

Is that possible? 

 

import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.jira.groovy.user.FormField
import groovy.transform.BaseScript
import org.apache.log4j.Level ;
import org.apache.log4j.Logger ;


log.setLevel(Level.DEBUG) ;
@BaseScript FieldBehaviours fieldBehaviours

getFieldByName("Requirement Type").setRequired(true)

if(getFieldScreen().name == "10_Dev - Waterfall FR Requirements Create Screen" || getFieldScreen().name == "10_Dev - Waterfall FR Requirements Edit Screen"){
def value = getFieldByName("Requirement Type").getFormValue() as String
if(value == "Functional"){
//set required on all fields related to functional, example below
getFieldByName("Correspondence").setRequired(false)
getFieldByName("Physical Requirements").setRequired(false)
getFieldByName("Implementation").setRequired(false)
getFieldByName("Recoverability").setRequired(false)
getFieldByName("Design Constraint").setRequired(false)
getFieldByName("Reliability and Fault Tolerance").setRequired(false)
getFieldByName("Usability").setRequired(false)
getFieldByName("Performance").setRequired(false)
getFieldByName("Supportability").setRequired(false)
getFieldByName("User Testing Requirements").setRequired(false)
}else if(value == "Non-Functional"){
//set required on all fields related to non functional, example below
getFieldByName("Correspondence").setRequired(true)
getFieldByName("Physical Requirements").setRequired(true)
getFieldByName("Implementation").setRequired(true)
getFieldByName("Recoverability").setRequired(true)
getFieldByName("Design Constraint").setRequired(true)
getFieldByName("Reliability and Fault Tolerance").setRequired(true)
getFieldByName("Usability").setRequired(true)
getFieldByName("Performance").setRequired(true)
getFieldByName("Supportability").setRequired(true)
getFieldByName("User Testing Requirements").setRequired(true)
}
}

 

 

Regards

Manas

Leo Community Leader Jan 29, 2020

@J Manas Kumar

Your code is correct for Create & Edit screens(Note: this condition is not required if script needs to be run on create & Edit screens)

If you replace this condition with screen name you placed in the transition of In progress to Complete status, behaviour will run only on that transition and validate those fields and make them mandatory as required

 

BR,

Leo 

HI @Leo 

Like i have mentioed those 2 screens earlier , i dont have any other screens in my workflow transition.

 

I have same 2 types of screens and my entire workflow follows the same 2 screen and any kind of Issues.

regards that  you have mentioned this "If you replace this condition with screen name you placed in the transition of In progress to Complete status" , i have attached one screenshot, i think i have one screen scheme only.rather than that i dont have anything.

 

 

Regards

Manasworkflow transition.PNG

Leo Community Leader Jan 29, 2020 • edited

gotcha...!

I won't suggest this BTW, instead Create one screen and add all those fields to that new screen(you can remove Summary, without filling Summary you can't create issue so it always holds data)

Refer this URL for details & Steps

And then Add this newly created screen in "In Progress" to "Completed" transition

Refer this URL for details & steps

And then include newly created screen name in behaviour script

Note: you should map this behaviour for "Requirement Type" field

you are done (y)

 

If your engineers make a completed transition from in progress, there will be new screen populated with those fields 

based on type field it's related fields will be made as mandatory(if they have value they can ignore them if not they have to fill those(mandatory) fields to complete the transition)

 

BR,

Leo

Hi @Leo   Can you help me on this?

I have a issue , my requirement is while creating that issue based on condtion i need to hide some of tabs present in its screen.

I wrote one behavior which work while editing but not working on create issue.

below i have pasted the code. with screen shot.

here while selecting "Project Type" == "Waterfall" then only i need to show these extra 4 fields otherwise i wont.

In the screen shot you can see if i select waterfall exra 4 fields should come, but even if i have not selected waterfall value its coming.

 

if(getActionName() as String == "Create") {

def projectTypeValue = getFieldByName("Project Type").getValue() as String
if(projectTypeValue != null) {

if(projectTypeValue == "Waterfall") {

showTab("BR Approvals")
showTab("FR Approvals")
showTab("SIT Test Plan Approvals")
showTab("UAT Test Plan Approvals")


}else{
hideTab("BR Approvals")
hideTab("FR Approvals")
hideTab("SIT Test Plan Approvals")
hideTab("UAT Test Plan Approvals")
}
}
}else{
hideTab("BR Approvals")
hideTab("FR Approvals")
hideTab("SIT Test Plan Approvals")
hideTab("UAT Test Plan Approvals")
}plan.PNG

 

 

Regards

Manas

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you