How to solve the following Error ?


I write the javascript in velocity file like

"#if($document.form.userNameContains.value == ($element.getName()));"

when i run this i got the following error , please tell me the solution to this error

($document.form.userNameContains.value) of '==' operation has null value. If a reference, it may not be in the context. Operation not possible. templates/allusers.vm [line 24, column 69]

2 answers

As Ive said previously, you are mixing server side and client side concepts, velocity != javascript.

Prefixing a # indicates that it is a velocity directive, this runs on the server and dissapears by the time it gets to the client. What you are seeing as a server side validation failure, because $document cannot be resolved on the server.

Perhaps you could explain what you are trying to achieve? Where is this velocity triggered from, an action? Perhaps you are looking for the current user that is available (if driven by an action) via $action.getLoggedInUser(), then you can use the various methods on the user for your comparison.

Try #if($document.form.userNameContains.value.equals($element.getName()));

Also check if both the values are not null

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Jan 08, 2019 in Jira

How to Jira for designers

I’m a designer on the Jira team. For a long time, I’ve fielded questions from other designers about how they should be using Jira Software with their design team. I’ve also heard feedback from other ...

807 views 3 9
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you