
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2014 12:34 PM
Hi all,
I'm trying to write a simple query in the HTML section of my UI Page:
<g:evaluate>
var today = new GlideDateTime();
var kb = new GlideRecord('kb_knowledge');
kb.addQuery('valid_to','>=',today);
kb.addQuery('published','<=',today); // Error here?
kb.query();
</g:evaluate>
However, the system won't let me save this due to the following error:
Error at line (26) The content of elements must consist of well-formed character data or markup.
I suppose that is because of the '<' character being interpreted as an HTML tag. I've tried using the escape character for HTML, but still no luck.
Any thoughts?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2014 12:44 PM
I've updated your code to escape your > and < for the UI Page. Also, I've added parameters to your g:evaluate tag to allow your query to be used by other parts of the document as 'jvar_kbarticles'. the last line of an evaluate becomes the value of the variable defined by it. (in this case, 'jvar_kbarticles' will contain the object 'kb' and can now be used by other elements of your document.)
<g:evaluate jelly="true" object="true" var="jvar_kbarticles">
var today = new GlideDateTime();
var kb = new GlideRecord('kb_knowledge');
kb.addQuery('valid_to','>=',today);
kb.addQuery('published','<=',today);
kb.query();
kb;
</g:evaluate>
Hope this helps!
Jerimy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2014 12:44 PM
I've updated your code to escape your > and < for the UI Page. Also, I've added parameters to your g:evaluate tag to allow your query to be used by other parts of the document as 'jvar_kbarticles'. the last line of an evaluate becomes the value of the variable defined by it. (in this case, 'jvar_kbarticles' will contain the object 'kb' and can now be used by other elements of your document.)
<g:evaluate jelly="true" object="true" var="jvar_kbarticles">
var today = new GlideDateTime();
var kb = new GlideRecord('kb_knowledge');
kb.addQuery('valid_to','>=',today);
kb.addQuery('published','<=',today);
kb.query();
kb;
</g:evaluate>
Hope this helps!
Jerimy

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2014 12:55 PM
Thanks Jerimy. I could've sworn I did the exact same thing, but I must have missed the other tags in the element header.