Hi everyone!
At the moment I have a system where a new issue is created by automation when the trigger issue is transitioned to a 'Ready' status.
In the 'Description' of the newly created ticket, I am trying to get automation to tag a user based on which user custom field (out of three) is not empty. These three custom fields are on both the trigger and created issue, and the created issue is copying the value of these three fields from the trigger issue
So ideally the automation would reference Custom Field 1
Custom Field 2
Custom Field 3
I've tried the following smart value:
{{#if(customfield_1)}}@[~{{customfield_1}}]
{{else}}
{{#if(customfield_2)}}@[~{{customfield_2}}]
{{else}}
{{#if(customfield_3)}}@[~{{customfield_3}}]
{{else}}[No user selected] {{/}}{{/}}{{/}}
but to no avail, i've tried including .accountid behind each custom field value, it also does not return anything. I'm no expert on this, so would apperciate any help on this.
Thank you!
Hi @Raycher
There is a format of the conditional logic which supports nesting: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-conditional-logic/#if
{{if(smartValue, "value if true", "value if false")}}
Thus for your case, it could be this:
{{if(customfield_1.accountId.isNotEmpty(),
customfield_1.accountId,
if(customfield_2.accountId.isNotEmpty(),
customfield_2.accountId,
if(customfield_3.accountId.isNotEmpty(),
customfield_3.accountId,
"No values selected")))}}
However with this syntax, the mention syntax could not be used in the conditional logic.
The workaround is to first create two created variables, one for the prefix and one for the suffix of the mention, and then concatenate the values:
And to get the total expression:
{{if(customfield_1.accountId.isNotEmpty(),
varMentionPrefix.concat(customfield_1.accountId).concat(varMentionSuffix),
if(customfield_2.accountId.isNotEmpty(),
varMentionPrefix.concat(customfield_2.accountId).concat(varMentionSuffix),
if(customfield_3.accountId.isNotEmpty(),
varMentionPrefix.concat(customfield_3.accountId).concat(varMentionSuffix),
"No values selected")))}}
Kind regards,
Bill
Hey Bill,
Thank you so much for this! The code you provided worked perfectly in returning the account id of the user in one of the three fields, however when executed the @ returned an unknown user.
So instead of using the 'Create Variable' function for the mention syntax, I used it to return the Account ID from the three custom fields:
{{if(customfield_1.accountId.isNotEmpty(),
customfield_1.accountId,
if(customfield_2.accountId.isNotEmpty(),
customfield_2.accountId,
if(customfield_3.accountId.isNotEmpty(),
customfield_3.accountId,
"No values selected")))}}
I then used the variable in the description of the created ticket as followed:
[~accountid:{{varSelectedUser}}]
and it worked perfectly!! Thank you so much @Bill Sheboy you helped solve a huge headache for me!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Raycher
Are the three fields you are checking in the trigger issue or the new issue you created?
When asking for help with an automation rule it will help us help you if you provide:
1. Screen images showing the entire rule
2. Screen images of any actions, branches, or conditions that are relevant to your question
3. The output in the rule Audit Log from when the rule executed.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey Trudy!
Apperciate your response, the three fields are present on both the trigger and created issue - the values are copied over from the trigger onto the created.
I don't think I'll be able to share SS due to confidentiallity issues, apologies on that. The actual rule is also very long and not really relevant to this specific issue I'm trying to fix.
I am happy to provide more information if necessary!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Raycher,
Without the details of the rule it will be difficult for us to provide assistance. Unexpected or incorrect rule behavior can be caused by the context in which steps are executed. We can't asses the context without the rule details.
In what type of rule component are you trying to use your code? Is this within the same Create Issue action you are using to create the issue, or in a separate Edit action?
If it is in the Create Issue action, then the three fields are not yet set within that issue, so they can't be used in your code. You would have to reference the values from the fields in the trigger issue. You could try prefixing the custom field references with triggerIssue.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That's right, it is within the same Create Issue action in the description section. I've tried using the triggerIssue as reference but no luck as well. Is the code that was provided valid? Or does something looks off?
If this does not work I may just create a seperate automation for this.
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.