Can anyone tell me why toUpperCase() in a behaviour script is not working.
def myField = getFieldById("customfield_14511")
def myField Value = myFile.getValue()
myField .setFormValue(myFieldValue.toUpperCase())
-----
Error message:
cannot find matching method java.lang.Object#toUpperCase()
Hi Peter
Keep in mind that many errors displayed in scriptrunner script editors are warning only.
This error is telling you that myFieldValue will be of type "object". That just means that the type was not specified.
And the toUpperCase() method is only designed to work on a String.
But during runtime, that object might very well be a string. So when you run the script it will be okay.
If you really want to avoid the error in the editor, you can strongly type your variable or perform explicit type conversions.
For example :
def myField = getFieldById("customfield_14511")
String myFieldValue = myField.getValue() //using String instead of def
myField.setFormValue(myFieldValue.toUpperCase())
Or
def myField = getFieldById("customfield_14511")
def myFieldValue = myField.getValue()
myField.setFormValue(myFieldValue.toString().toUpperCase()) //explicitly convert to string
thanks a lot Peter-Dave,
you are of course right and the script runs withour any errors.
Peter
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.