You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
hi there,
I am getting out of idea - even after reading tons of other amazing tricks read in the community
I have created a custom variable (reporterdetails) which contains below information - but both values will be variable - just example values
{office=Munich, department=880}
Using J4A I will need to split a string as I want to use these values in other jira fields
I want to have the value for office and department
ideally one result should be "Munich" (for the office") and the other one "880" (for the department)
I have managed to get the office value
{{reporterdetails.substringBetween("{office=",",")}}
// returns "Munich"
however I don´t find a way yet just to get "880"
{{reporterdetails.split(",").last}}
// returns "department=880}"
// => however I then I would need remove "department=" & the ending "}"
Furthermore tried a lot using .match(<regex>) but this regex integration is just horrible in my mind - in short didn´t get it to work
Thought also to use .substring(X,Y)}} but I don´t know how to calculate it dynamically as the value (and length) will change.
Hi @felix.weber
Would subStringAfter work? So something like this?
{{data.substringAfterLast("=").remove("}")}}
The remove would then lose the extra }
However, this does assume that the format of the variable will remain the same. So that department will always be last.
You could do the same for the first value with substringAfterFirst, but that will also get the second value.
I hope this helps in some way. And yes, regex's are evil.
hey @markwhaite it works - I thought I have tested this but obviously not in combination with .remove
thx again
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
me again.. it is getting more complicate
the variable (JSON data) contains following informatoin:
{office=Munich, department=000 - Heros, managerID=123, managerEmail=test.user@domain.com, ID1=456, ID2=789}
can somebody help maybe with working regex / in J4A with .catch or similar ? I guess we are at the limits of the text manipulations ?!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
super strange this time it works like a charm
just changing .substring.after & .substring.before
reporterdetails office = {{reporterdetails.substringBetween("{office=",",")}}
reporterdetails department = {{reporterdetails.substringAfter(", department=").substringBefore(", managerID")}}
reporterdetails managerID = {{reporterdetails.substringAfter(", managerID=").substringBefore(", managerEmail")}}
reporterdetails manager Email : {{reporterdetails.substringAfter(", managerEmail=").substringBefore(", ID1")}}
reporterdetails ID1 : {{reporterdetails.substringAfter(", ID1=").substringBefore(", ID2")}}
reporterdetails ID2" : {{reporterdetails.substringAfterLast("=").remove("}")}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
to make it bit more complicated:
{office=Munich, department=xxx, managerid=123456789}
I am able to get the value for office & manager ID
office =
{{reporterdetails.substringBetween("{office=",",")}}
manager ID =
{{reporterdetails.substringAfterLast("=").remove("}")}}
but I am struggeling to get the value for the department.
Tried e.g. to chain substringbetween, .substringafterlast etc like
only department:
{{reporterdetails.substringBetween({{reporterdetails.substringAfter(", department=")}},{{reporterdetails.substringBeforeLast(",")}})}}
however no result at all
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
fixed it by myself:
{{reporterdetails.substringAfter(", department=").substringBeforeLast(",")}}
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.