Hello,
I want create a Task in a Software project, after a Change Request in a Service Management project reached a specific status.
Also, I created a custom drop-down field "Epic Parent", which value is selected in the Change Request and is used to assign the later created Task to an Epic. The values of this custom field have the format "[Epic Name] *[Epic Key]", like "Application Log *TEST-137".
My problem is now, that I can't get the needed Epic Key "TEST-137" from this string.
This JSON:
Results in:
Unfortunately, this is my first time working with JSON & smart values. I tried the same statement without the substringAfterLast() function, which gives me the expected result of the whole field value. Also for testing purpose, I tried the substringAfter() function and with simple letters, instead of the "*", but all seems to result in an empty return.
Am I using the function wrong, or is there another way to get the Epic Key out of my string?
Some things I wonder:
{{issue.Epic Parent.substringAfterLast("TEST")}}
Kind regards,
Bill
Hi Bill,
thanks a lot for your response!
1. Yes, if I work with "Epic Link": "{{issue.Epic Parent}}", I get the value I expect:
Error creating issue
Epic with key 'Test 4 *DTP-21' does not exist., Specify a valid value for the Epic Link (customfield_10002)
If I now try to just get the needed part "DTP-21" from this string, like with "Epic Link": {{issue.Epic Parent.substringAfterLast("*")}}, it seems that I get an empty return:
Error creating issue
Epic with key '' does not exist., Specify a valid value for the Epic Link (customfield_10002)
2. Yes, exact the same behavior on every results if I use "customfield_10485" instead of "Epic Parent".
3. I haven't known that this is possible so far, I thought that's why JSON is there ;). I gave it a try with:
This resulted in the same first error from point 1., just like expected. If I now also here try to extract the needed Epic Key from this string, the automation runs successfully with no errors, but there is no Epic Link in the created Task. Maybe we get here also an empty return, but this doesn't cause an error here and just leave the Epic Link empty?
4. I gave it a try with different delimiter and different string separator, even with split(). I get always the same JSON error mentioned in 1., and always the same behavior if I use just the smart value mentioned in 3.
I even gave it a try with "Epic Link": "{{issue.customfield_10485.length()}}" which should return the error:
Error creating issue
Epic with key '14' does not exist., Specify a valid value for the Epic Link (customfield_10002)
But also this function seems to return an empty result, causing this error instead again:
Error creating issue
Epic with key '' does not exist., Specify a valid value for the Epic Link (customfield_10002)
Is it possible, that these functions doesn't even work with strings from (my) drop-down Custom Field?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
My last sentence made me try it with another field with JSON. It all works fine with the standard Summary field.
Then I tried fields like Request Type, Components, Urgency, Approvers which all didn't worked. So I created a custom single line text field, and it worked fine just as the Summary field.
To sum it up: {{issue.Field Name}} works fine for me to get a value of any field of an issue, but if I want to use a function like {{issue.Field Name.length()}}, it needs to be an text field to work.
I could have saved the time by reading, that these smart values are (unfortunately) only meant for text fields: Smart values - text fields | Jira Software Cloud | Atlassian Support
So is there a way to extract part of strings from other fields, like in my case drop-downs?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I did not see a post with the result I was expecting from the audit log write, so let's try this:
1) Please post an image of your complete rule, as you are currently trying it.
2) Please create another short rule to test your field contents:
Then please run rule #2 with an issue which has the field set and post the audit log results.
Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Bill,
thanks, that it! So all I needed was to add .value to solve my problem:
{{issue.Epic Parent.value.substringAfterLast("*")}}
Thanks a lot!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Awesome! I am glad to learn that worked.
__Bill
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.