- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2015 08:45 AM
Hi,
Can we use variable in Encoded query, I am trying to assign a value to variable and use it in the encoded query it doesn't seems to be working. Can any one let me know how to do this. Below is the code, I wanted to replace the sysid highlighted with the variable X declared.
var a = new GlideRecord('u_backup_job');
a.addEncodedQuery("u_backup_system=Idera^u_status=failed^sys_created_onBETWEENjavasc#ipt:gs.hoursAgo(3)@javasc#ipt:gs.minutesAgoStart(1)");
a.query();
while(a.next())
{
var x = a.u_client_host;
var b = new GlideRecord('u_mon_hosts');
b.addEncodedQuery("u_active=true^u_host=9a5fdfe5301ad54c915a54999ba031b3^u_service_check.u_display_name=MSSQLSERVER");
b.query();
if(b.next())
{
gs.log("Create ticket");
}}
Thanks,
Krishna.
Solved! Go to Solution.
- 6,887 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2015 08:51 AM
Hi Krishna,
Yes you can use a variable, you need to use the concatenation operator "+":
b.addEncodedQuery("u_active=true^u_host=" + x + "^u_service_check.u_display_name=MSSQLSERVER");
Please read the following link for more information regarding the concatenation operator:
Arithmetic operators - JavaScript | MDN
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2015 08:51 AM
Hi Krishna,
Yes you can use a variable, you need to use the concatenation operator "+":
b.addEncodedQuery("u_active=true^u_host=" + x + "^u_service_check.u_display_name=MSSQLSERVER");
Please read the following link for more information regarding the concatenation operator:
Arithmetic operators - JavaScript | MDN
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2015 12:29 PM
Thanks Edwin..