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 All,
I've a groovyscript where i want to find an objectID of a field from inside. It succeeds partially.
i use:
def app_newcustomField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_14100");
def app_newValue = issue.getCustomFieldValue(app_newcustomField);
And as result i get :
app_newValue = [Interne Test apparaat (DM-453739)]
I only want the Key DM-453739 and not also the label.
Can somebody help me with the right notation to get it?
Thx
I guess you are using a field that is not a standard type field.
First, do you expect 1 or multiple values ?
If only one you can get rig of the [ ] using first() fucntion.
def app_newcustomField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_14100");
def app_newValue = issue.getCustomFieldValue(app_newcustomField)?.first();
Then you can use a regex to get what is between the ().
Regex is (?<=\()(.*?)(?=\))
The code should be something like
app_newValue = (app_newValue =~ / (?<=\()(.*?)(?=\))/)[ 0 ][ 1 ]
You may have to add some code to validate there is something that have match
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.