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
Hi @Kumar_ G 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.
Type comment?.body instead
That worked.
Thank You
It looks like you're new here. Sign in or register to get started.