Documentation for JIRA 6.3 EAP developer (EAP) releases only. Not using this? See below:
(JIRA 6.2.x documentation | JIRA OnDemand documentation | earlier versions of JIRA)

Skip to end of metadata
Go to start of metadata

Scenario

When programming in Jelly, you can get in a situation as illustrated by the following code snippet:

The goal here is to create a new Project Role and then set the appropriate Permissions to it. However, as the projectroleid and qaroleid variables are have not the same type, you should get an error like this:

So qaroleid, which received a java.lang.Long value from the jelly.role.id context variable, should be converted to a java.lang.String type so it can be informed as projectroleid attribute when setting a Permission.

Problem

How can you convert types in Jelly?

Solution

You can use the invoke Jelly tag to call the method toString on the jelly.role.id context variable and store this value the in the qaroleid variable. So you should replace this line...

... with this...

... and the script will work sucessfully.

You can also (just as an example matter) use the new Jelly tag to convert the java.lang.String value of the qaroleid variable into a java.lang.Float value and store it in the qafloatvar variable, as shown here:

You may find useful to look at these pages for more information on Jelly tags:

  • No labels

1 Comment

  1. How could i convert a string to a org.ofbiz.core.entity.GenericValue?