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.
×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...
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";
}
Thank you @David Fischer - works as described :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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...
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@David Fischer thanks very much for your time and efforts!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The second method worked for my needs fortunately 😁
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for advice @Fabian Lim
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
They are pretty vague on their examples unfortunately
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.