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.