- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2016 11:17 AM
I am just trying to run an encoded query in a UI Page. I have run many encoded queries, but this is not working.. at all..
Here is my query:
function Total()
{
var counter = 0;
var queryString = 'sys_created_onONThis month@javascript:gs.beginningOfThisMonth()@javascript:gs.endOfThisMonth()';
var gr = new GlideRecord('myTable');
gr.addEncodedQuery(queryString);
gr.query();
while(gr.next())
{
alert('1');
}
}
Any ideas?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2016 11:37 AM
Hi Josh,
If you have written this code on ui page client script then the script will be like this:
function Total()
{
var counter = 0;
var queryString = 'sys_created_onONThis month@javascript:gs.beginningOfThisMonth()@javascript:gs.endOfThisMonth()';
var gr = new GlideRecord('myTable');
gr.encodedQuery=queryString;
gr.query();
while(gr.next())
{
alert('1');
}
}
if you have written on ui page HTMl, then the code will be like this:
function Total()
{
var counter = 0;
var queryString = 'sys_created_onONThis month@javascript:gs.beginningOfThisMonth()@javascript:gs.endOfThisMonth()';
var gr = new GlideRecord('myTable');
gr.addEncodedQuery('queryString');
gr.query();
while(gr.next())
{
gs.addInfoMessage('1');
}
}
Thanks,
Farukh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2016 11:26 AM
This is a Server Side script... you're not going to see an alert message. That's a client side function. Try changing it to something like:
gs.addInfoMessage('record found: ' + gr.getDisplayValue());

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2016 11:31 AM
Where exactly you are using this code in the UI page?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2016 11:37 AM
Can you try this "Without Space in between This month"
var queryString = 'sys_created_onONThismonth@javascript:gs.beginningOfThisMonth()@javascript:gs.endOfThisMonth()';
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2016 11:37 AM
Hi Josh,
If you have written this code on ui page client script then the script will be like this:
function Total()
{
var counter = 0;
var queryString = 'sys_created_onONThis month@javascript:gs.beginningOfThisMonth()@javascript:gs.endOfThisMonth()';
var gr = new GlideRecord('myTable');
gr.encodedQuery=queryString;
gr.query();
while(gr.next())
{
alert('1');
}
}
if you have written on ui page HTMl, then the code will be like this:
function Total()
{
var counter = 0;
var queryString = 'sys_created_onONThis month@javascript:gs.beginningOfThisMonth()@javascript:gs.endOfThisMonth()';
var gr = new GlideRecord('myTable');
gr.addEncodedQuery('queryString');
gr.query();
while(gr.next())
{
gs.addInfoMessage('1');
}
}
Thanks,
Farukh