I'm trying to get a value from the Organizations field in JSD without the brackets.
Using ${issue.get("customfield_10002")*.name.flatten()} will get me the organization name, but puts it in brackets. How do I get rid of those?
Hi David,
Try issue.getAsString("customfield_10002"). This returns a string representation of the value of issue field. Please check the Groovy console provided by the app. It has a help system with Groovy scripts showing how to access issue fields and much more.
Regards,
Radhika
One way is to use substrings; I use the following function in a script to accomplish this.
def stripBrackets(String str){String retStr = strif(str == null || str.length() < 2){return str}if(retStr.substring(0,1).equals("[")){retStr = retStr.substring(1)}if(retStr.substring(retStr.length()-1).equals("]")){retStr = retStr.substring(0,retStr.length()-1)}return retStr}
@Payne thanks for getting back to me. I'm not sure how I would use that substrings script. I'm using the JMWE plugin with groovy code.
${issue.get("customfield_10002")*.name.flatten()} gets me a value that looks exactly like this with the brackets: [some organization name].
Do you know how I would be able to use the substrings in groovy code so the result of "getting" customfield_10002 is just "some organization name" with no brackets?
That just gives me the id of the organization and not the name.For instance:issue.get("customfield_10002")
Returns with this:
[CustomerOrganizationImpl{id=159, name=some company name}]
Where as:
issue.getAsString("customfield_10002")
Returns with:
159
I'm trying to access the name part of this without brackets.
Oh yeah. issue.get("customfield_10703")*.name.flatten() returns an array of Strings. Use the join operator to get just the name(s).
issue.get("customfield_10703")*.name.flatten().join(",")
This solved it for me. Thank you!
It looks like you're new here. Sign in or register to get started.