Dear community,
I used something like
"customfield_2": { "value": "{{#if(equals(triggerIssue.fields.customfield_1.value, "Option 1 name in Project A"))}}Option 1 Name in Project B{{/}}{{#if(equals(triggerIssue.fields.customfield_2value, "Option 2 name in Project A"))}}Option 2 Name in Project B{{/}}"
Is there a way to reference the options of a custom field based on the option id instead of their name? I know how to find the option id in the custom field settings but I don't know how to do the mapping and didn't find yn documentation
If anyone has a clue, please let me know :)
Yes, and...to the other suggestions offered:
I recommend using a lookup table rather than conditional logic to translate the field value. That will be easier to maintain / debug in the rule. Please look here to learn more about lookup tables:
Kind regards,
Bill
To reference the option ID in the field you can use the following smart value:
{{issue.CUSTOM_FIELD.id}}
Best regards
Sam
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Philip Kroos - TEAM XALT --
I think this should work:
"customfield_2": { "id": "{{#if(equals(triggerIssue.fields.customfield_1.id, "optionId-1-a"))}}optionId-1-b{{/}}{{#if(equals(triggerIssue.fields.customfield_2.id, "optionId-2-a"))}}optionId-2-b{{/}}"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Documentation for Advanced Field Editing for Single-select custom fields:
Select a single value from a defined list of values. You can address them by value or id.
"customfield_11449" : { "value": "option3" }
or
"customfield_11449" : { "id": 10112 }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Darryl Lee , I agree, this should work, yet it doesn't :(
My formula is currently
"customfield_10632":
{ "id": "{{#if(equals(triggerIssue.fields.customfield_10633.id, "11392"))}}11390{{/}}{{#if(equals(triggerIssue.fields.customfield_10633.id, "11393"))}}11391{{/}}"
In other words, the mapping is as follows:
Maybe I'm missing something obvious but the formula should work
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Context is important for automation rule questions, so without seeing your complete rule and where that expression is used, diagnosis is challenging.
One thing is certain: please note you have nested the double-quotation marks in the expression, and so that is unlikely to evaluate correctly. The workaround for that would be to determine the id value, saving it to a variable, and then use that variable in the JSON expression.
Kind regards,
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Bill Sheboy speaks the truth about nested double-quotes. I missed that. And yes, screenshots would helpful here.
ALSO helpful: Audit logs.
You can put the full expression into an Audit log, but you also should put pieces of it, like:
{{triggerIssue.fields.customfield_10633.id}}
and
{{#if(equals(triggerIssue.fields.customfield_10633.id, "11392"))}}11390{{/}}
I wonder too if maybe Automation might treat option ID as an integer, then maybe you could skip the quotes altogether and use eq instead of equals? This is a BIG IF:
{{#if(triggerIssue.fields.customfield_10633.id.eq(11392))}}11390{{/}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
OR, I'm an idiot and didn't read the docs I quoted:
"customfield_11449" : { "id": 10112 }
You don't need quotes around the option ID. So you want this:
"customfield_10632":
{ "id": {{#if(equals(triggerIssue.fields.customfield_10633.id, "11392"))}}11390{{/}}{{#if(equals(triggerIssue.fields.customfield_10633.id, "11393"))}}11391{{/}} }
(I removed the quotes around the ID, and added a closing brace that you missed.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Darryl Lee , in the end we decided to not use ids but values, this makes the automation work. However, if we don't fill the field for customfield_10633, the automation doesn't work ("Error creating issue Specify a valid value for NAME (customfield_10632)")
I tried {{#if(equals(triggerIssue.fields.customfield_10633.value,NULL))}}{{/}} but this doesn't work and still gives me the same error message. Basically, if customfield_10633 is empty, customfield_10632 should also remain empty when creating a new issue
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Philip Kroos - TEAM XALT -
I'm wondering if you could add an IF block that checks if {{triggerIssue.fields.customfield_10633}} is EMPTY before it even attempts to do the Edit.
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.