How to use "AND" operator in ServiceNow UI page using Javascript?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2018 06:17 AM
I tried "&&" symbol its not working. Someone suggest me which symbol comes in the place of AND in below code:
If(Condition1==true AND Condition2==true)
{
}
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2018 06:42 PM
Inside of Javascript, there should be no issue with using &&
as it's an ECMAscript (the standard Javascript is based upon) logical operator. The AND
keyword won't work as it's not recognised as a valid operator.
^
also won't work as in Javascript it's a bitwise XOR operator.
A single &
is the bitwise AND operator.
What is the specific error you're encountering? There's every possibility it's a code error rather than a language construct one.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2018 11:06 PM
Hi benjamin,
Inside the servicenow UI page "&" operator not working.It shows error "The entity name must immediately follow the '&' in the entity reference."

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2018 11:12 PM
Try converting your &&
to &&
in your script and see if that makes a difference.
It seems like you're running into an XML entity reference error, because the ampersand is one of its protected operators and &&
fails the operator entity reference.
Alternatively, in general XML best practice terms, you could wrap your code in CDATA
tags like so:
<![CDATA[
... code
]]>
The idea there is that you force the parser to treat the data as potentially volatile, that is it won't interpret it as XML and instead takes it as the character data as literal.