Hello,
I am trying to get the last comment data from the issues which I am able to. But if there is no comment then I am getting null error. Is there a way to put in a default value if it is empty?
Regards,
Sunil
I would use and if/else statement or the elvis operator. If e.g. you have something like the only below:
def comment = commentManager.getLastComment (issue)
comment.body
Then you could write:
if (comment.body == null) {
DEFAULT VALUE HERE
} else { comment.body }
OR
comment.body==null?DEFAULTVALUE_GOESHERE:comment.body
Hi Alex,
I am getting an error that .body cannot run on null value.
Regards,
Sunil
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Kindly mark my answer as accepted in order to help others in the community with the same questions. Thank you!
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.