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

worklow condition test if a drowdown customfield selective value does not includes another field

Cem Tuğrul October 29, 2023

Dear People,

I am really newbie writing  workflow. I need a condition while creating an issue.I have a selective dropdown customfield values as A or B. Then I have another dropdown customfield values as "A_XYX" "A_TVY" "B_CVY" "B_TVZ"

When I select "A" from the first customfield then I can only select "A_XYX" or "A_TVY"

If this not meet then I need a message like "You can not select "B_CVY" or "B_TVZ" when the first custom filed selected as "A"

 

 

2 answers

2 accepted

2 votes
Answer accepted
Joseph Chung Yin
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 29, 2023

@Cem Tuğrul -

If you are using WF to achieve your ask, then essentially you will need to add "validator" to your WF's transition step, so one cannot complete the WF transition if there is a mis-match between your two custom fields value.

I don't believe a WF is the right approach for your situation.  Currently, you should take a look at the following paid add-on -  

https://marketplace.atlassian.com/apps/6820/scriptrunner-for-jira?hosting=datacenter&tab=overview

Where it has a component named "Behavior"and you can setup option control of a field based on another field's value selection to configure the setup.

Hopefully this helps + your organization already have migrated your Server env to either Datacenter or Cloud env because the Server env will be de-supported by Atlassian on Feb 2024. 

Best, Joseph Chung Yin

Jira/JSM Functional Lead, Global Technology Applications Team

Viasat Inc.

Cem Tuğrul October 29, 2023

thank you Joseph,

We are on the way of Datacenter.

I have also script runner but I do not know how to realize:-) Is there any asked and solved

on the community such a kind of my problem

Joseph Chung Yin
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 29, 2023

@Cem Tuğrul -

Since you are using ScriptRunner for Jira in your environment, please ensure that you take a look at setting Behavior configuration setup.

With Behavior configuration setup, you don't need to use the WF to achieve what you wanted.

https://docs.adaptavist.com/sr4js/latest/features/behaviours

Here is an example from ScriptRunner for Jira library using Behavior configuration - https://docs.adaptavist.com/sr4js/latest/features/behaviours

Hope this helps.

Best, Joseph

Cem Tuğrul October 30, 2023

I have looked at the sites but could not find a smiliar solution for me.

Thx

Joseph Chung Yin
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 31, 2023

@Cem Tuğrul -

We have been using the Behavior component in our env extensively, so if you can provide me with more details of your needs, I can try to come up with the solution example to share with you as a start.

Best, Joseph

Cem Tuğrul November 1, 2023

Thank you very much for your kind concern and supprt. 

Cem Tuğrul November 5, 2023

Here is my script but it gives error ;

def Welches System = getFieldById("customfield_25108")
def Welcher Service/Betroffene Kachel = getFieldById("customfield_25203")

if(Welches System.getValue()){
def selectedOption = Welches System.getValue() as String
if(selectedOption == "MKH"){
Welcher Service/Betroffene Kachel.setHidden(true)
Welcher Service/Betroffene Kachel.setRequired(false)
}else{
Welcher Service/Betroffene Kachel.setHidden(false)
Welcher Service/Betroffene Kachel.setRequired(true)
}
}

 

what I am wanting if the customfield_25108 is as a value select "MKH" then my other cascade type customfield_25203 hidden(true) and requied(false)

the other options for my  customfield_25108 ;

"None"

"NKH"

When selected value as "NKH"  then customfield_25203 required(true)

Joseph Chung Yin
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 5, 2023

@Cem Tuğrul -

What kind of error that your above script is throwing?  Looking at the script, I recommend you don't use "/" character in variable definition.  In addition, your variable definition also contains a space in the variable name - this is not allowed. 

Try to change the "/" to "_" and replace the space character with "_" too see if your script will work or not.

Example - 

  • def Welcher Service_BetroffeneKachel = getFieldById("customfield_25203")

Secondly, your outer if is not needed.  You can just populate the selectedOption variable and use it for the if/else condition.


def selectedOption = Welches System.getValue() as String

if(selectedOption == "MKH"){
Welcher Service_Betroffene_Kachel.setHidden(true)
Welcher Service_Betroffene_Kachel.setRequired(false)
}else{
Welcher Service_Betroffene_Kachel.setHidden(false)
Welcher Service_Betroffene_Kachel.setRequired(true)
}

 

Best, Joseph

Cem Tuğrul November 5, 2023

I have changed my script as Joseph's advise then it's working;

 

def WelchesSystem = getFieldById("customfield_25108")
def WelcherServiceBetroffeneKachel = getFieldById("customfield_25203")

if(WelchesSystem.getValue()){
def selectedOption = WelchesSystem.getValue() as String
if(selectedOption == "MKH"){
WelcherServiceBetroffeneKachel.setHidden(true)
WelcherServiceBetroffeneKachel.setRequired(false)
}else{
WelcherServiceBetroffeneKachel.setHidden(false)
WelcherServiceBetroffeneKachel.setRequired(true)
}
}

 

Thank you very much JC

Joseph Chung Yin
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 5, 2023

@Cem Tuğrul -

You are welcome and excellent that my inputs resolved your problem.  For efficient coding you don't need the outer if statement in your script -

if(WelchesSystem.getValue()){


def selectedOption = WelchesSystem.getValue() as String
if(selectedOption == "MKH"){
WelcherServiceBetroffeneKachel.setHidden(true)
WelcherServiceBetroffeneKachel.setRequired(false)
}else{
WelcherServiceBetroffeneKachel.setHidden(false)
WelcherServiceBetroffeneKachel.setRequired(true)
}


}

Best, Joseph

Cem Tuğrul November 5, 2023

I have saved this behavior script. Now I go to my WF and edit in"create" in validator.

How can I call this saved behavior?

Joseph Chung Yin
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 6, 2023

@Cem Tuğrul -

This is a setup for Behavior configuration for your project, you don't call this script within your WF's validators setup.

Best, Joseph

Cem Tuğrul November 6, 2023

the script is OK but while creating issue it did not work

Joseph Chung Yin
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 6, 2023

@Cem Tuğrul -

What was the error message?  Why don't you just use Scriptrunner's Behavior configuration to execute your action.  You don't have to add it as a validator in the WF.

Best, Josehp

Cem Tuğrul November 6, 2023

I am trying to create issue when I select "MKH" or "None"  for "customfield_25108

the custom field customfield_25203 still appearing

Cem Tuğrul November 6, 2023

def WelchesSystem = getFieldById("customfield_25108")
def WelcherServiceBetroffeneKachel = getFieldById("customfield_25203")

if(WelchesSystem.getValue()){
def selectedOption = WelchesSystem.getValue() as String
if(selectedOption == "MKH" || selectedOption == ""){
WelcherServiceBetroffeneKachel.setHidden(true)
WelcherServiceBetroffeneKachel.setRequired(false)
}else{
WelcherServiceBetroffeneKachel.setHidden(false)
WelcherServiceBetroffeneKachel.setRequired(true)
}
}

Cem Tuğrul November 6, 2023

The shortest way of my purpose is ;

customfield_25203 is the only required(true) & hidden(false) when the "customfield_25108" ="NKH" 

Cem Tuğrul November 6, 2023

Could it be something wrong while creating behaviour over behaviours screen?

I have done add mapping and selected for my project and issue type

Joseph Chung Yin
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 6, 2023

@Cem Tuğrul -

Please read my previous suggestions -

1) In your code setup in Behavior configuration, you have extra calls which are not needed (remove the highlighted/strikethrough lines)

 

def WelchesSystem = getFieldById("customfield_25108")
def WelcherServiceBetroffeneKachel = getFieldById("customfield_25203")

if(WelchesSystem.getValue()){
def selectedOption = WelchesSystem.getValue() as String
if(selectedOption == "MKH" || selectedOption == ""){
WelcherServiceBetroffeneKachel.setHidden(true)
WelcherServiceBetroffeneKachel.setRequired(false)
}else{
WelcherServiceBetroffeneKachel.setHidden(false)
WelcherServiceBetroffeneKachel.setRequired(true)
}
}

 

How did you setup your Behavior configuration?  (via initializer or actual field with serverside scripting)

Best, Joseph

Cem Tuğrul November 6, 2023

 

from behaviour directly amd made mapping

Cem Tuğrul November 6, 2023

from behaviour of jira and made mapping for project and issue

Cem Tuğrul November 6, 2023

behavior.png

Cem Tuğrul November 6, 2023

create_issue.png

Cem Tuğrul November 6, 2023

when the value "MKH"  the other custom field(under) still appearing or when it is "None"

Joseph Chung Yin
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 6, 2023

@Cem Tuğrul -

Thanks for your update.  In this case remove the initializer setup and move the script code against the "Welches System" field and add the script codes using "Add server-side script" option.

Best, Joseph

Cem Tuğrul November 6, 2023

server_side.png

Cem Tuğrul November 6, 2023

still nothing has changed

Cem Tuğrul November 6, 2023

Yeah I found my mistakes;

1- There was a still requried validation for mycustomfield_25203

2- There ware many saved behaviours for mu purpose when I have deleted and created final one. Then it worked by JY's solution

 

Thank you very much JY again :-)

0 votes
Answer accepted
Cem Tuğrul November 1, 2023

BTW,

 

I have solved my problem without any script. Here is my solution just create cascade customfield

then put your 2 values or more. 

then  click configuration for your values then again fill in the other values So let say your master 

customfields Values as A,B,C 

then you want to select from other customfieds values depending on selecting from A,B,C

just go to cascade customfield and do configure for each value so just add values for each one.

 

When I select A then I can only select other values from A  and when selecting B again values for B and so on...

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events