Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 21:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.

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

Set "select type" custom field value based on value of another "select type" custom field?

Pete P
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 30, 2021

Using the "Set field value (JMWE app)" post function I need to set the value of a custom field based on the values of another.

Custom Field 1: "Grant Type" (A,B,C)
Custom Field 2: "Team Queue" (1,2,3,4,5)


If "Grant Type" selectedValue = A set "Team Queue" selectedValue to 5
If "Grant Type" selectedValue = B set "Team Queue" selectedValue to 4
If "Grant Type" selectedValue = C set "Team Queue" selectedValue to 2...

 

What is the proper syntax for this? I am struggling with it...

2 answers

2 accepted

2 votes
Answer accepted
David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 30, 2021

Hi @Pete P 

using JMWE's Set Field Value post-function, you can easily achieve this.

As the "Field to set", select your Team Queue field.

As the Value type, select "Groovy Expression"

As the Value, use a script like:

switch (issue.get("Grant Type")) {
case "A": return 5;
case "B": return 4;
case "C": return 2;
}

This assumes that the Team Queue field is a Number field. Otherwise, you'll need to return a String instead:

switch (issue.get("Grant Type")) {
case "A": return "5";
case "B": return "4";
case "C": return "2";
}
Pete P
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 31, 2021

Thank you @David Fischer  - works as described :)

Pete P
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 31, 2021

@David Fischer  - one more question if I may ask. 
Above works perfectly for my single select lists. 

Do you know syntax to use for determining the "case" value with custom field type "Select List (cascading)" ?  

In this field type there is parent option and selected value.  If I just use selected value for case it doesn't work, also I tried "parent option - selected value" which also does not work.  

David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 31, 2021

Hi @Pete P ,

well, it depends on how you want to treat the parent and child options. Do you have a different Team Queue value for each combination of parent and child values? Or is it based just on the parent value?

If it's based on the combination of parent and child, you can do something like:

switch (issue.get("customfield_10202")?.get(null)?.value) {
case "Parent A":
switch (issue.get("customfield_10202")?.get("1")?.value) {
case "Child 1": return "A.1"
 case "Child 2": return "A.2"
}
  case "Parent B":
switch (issue.get("customfield_10202")?.get("1")?.value) {
case "Child 1": return "B.1"
  case "Child 2": return "B.2"
}
}

If neither the parent nor the child values can contain a comma (","), then you can also use a single switch, knowing that the parent value and child value will be separated with a comma:

switch (issue.getAsString("customfield_10202")) {
case "Parent A,Child 1": return "A-1"
 case "Parent A,Child 2": return "A-2"
 case "Parent B,Child 1": return "B-1"
//etc...
}
Pete P
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 3, 2022

@David Fischer  thanks very much for your time and efforts!

Pete P
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 3, 2022

The second method worked for my needs fortunately 😁

0 votes
Answer accepted
Fabian Lim
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 30, 2021

Hi @Pete P

I believe the "Set field value" post-function has a lot of limitations.  Use the "Scripted Groovy" post function instead.

You can follow the instructions here for the scripted groovy post function: https://innovalog.atlassian.net/wiki/spaces/JMWE/pages/139635057/Scripted+Groovy+operation+on+issue

Regards

Pete P
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 30, 2021

Thanks for advice @Fabian Lim 

Pete P
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 30, 2021

They are pretty vague on their examples unfortunately

Suggest an answer

Log in or Sign up to answer