Want to get rid of Google Ads, click here.
+ Reply to Thread
Results 1 to 9 of 9

Thread: Link query using javascript

  1. #1
    Junior Member
    Join Date
    Feb 2008
    Posts
    5

    Default Link query using javascript

    Hi

    When creating links with a query condition there is a separat tab which allows you to use javascript.

    I have not been able to use this. Could someone post an example of how to specify a "link query" with javascript which returns some values?

    Thanks in advance :-)



    /John

  2. #2
    Administrator tommy's Avatar
    Join Date
    Nov 2001
    Location
    Copenhagen
    Posts
    4,272

    Default

    In the query field specify a variable like $query

    In the javascript do one of 2 things:

    1: pass the query with return in the javascript and call the script like this

    system.vars.$query=scriptlibrary.function(paramete rs);

    2: set the variable inside the javascript

    system.vars.$query="the query you have built"
    Best regards Tommy
    Blog - - ITIL certified - Accredited Integration Specialist – HP OpenView Service Management

    Want to keep this site alive? Consider making a donation. Click here.

  3. #3
    Junior Member
    Join Date
    Feb 2008
    Posts
    5

    Default

    Thank you. I have not been able to test this yet.

    If I write an sql query in the javascript, e.g. "id>234", which returns many values - will this work and will all the values be displayed in a list for the user?

  4. #4
    Administrator tommy's Avatar
    Join Date
    Nov 2001
    Location
    Copenhagen
    Posts
    4,272

    Default

    It should yes.
    Best regards Tommy
    Blog - - ITIL certified - Accredited Integration Specialist – HP OpenView Service Management

    Want to keep this site alive? Consider making a donation. Click here.

  5. #5
    Junior Member
    Join Date
    Feb 2008
    Posts
    5

    Default Cannot make this work

    Hi

    Thank you for your help, but I have not been able to accomplish this yet.

    Under the javascript tab i have written a query:

    var fDevice = new SCFile("device");
    var myLogicalName = "ACME Phone 0001";
    var sql = "logical.name=\"" + myLogicalName + "\"";

    if (fDevice.doSelect(sql) == RC_SUCCESS ) {
    system.vars.$query=fDevice;
    } else {
    system.vars.$query=NULL;
    }

    But this query does not seem to trigger as the result returned is all devices. If I remove the javascript, the same result is returned.

    I have specified query in the "Add Query Column".

    Thanks.

    /John

  6. #6
    Senior Member glg's Avatar
    Join Date
    Aug 2004
    Location
    Chicago, IL, USA
    Posts
    714

    Default

    you're passing the device record to the query, that's not what you want. You want to pass the query you used, so pass the variable sql to $query.

  7. #7
    Junior Member
    Join Date
    Feb 2008
    Posts
    5

    Default can't make this work...

    I am struggeling...

    I have the following in the javascript section of the link:

    var myLogicalName = "ACME Phone 0001";
    system.vars.$query="logical.name=\"" + myLogicalName + "\"";

    Still all records are returned - it looks like SM does not care about the javascript statement.

    Please see attached image.

    /John
    Attached Images

  8. #8
    Administrator tommy's Avatar
    Join Date
    Nov 2001
    Location
    Copenhagen
    Posts
    4,272

    Default

    Try a print statement to see if the javascript is executed.
    Best regards Tommy
    Blog - - ITIL certified - Accredited Integration Specialist – HP OpenView Service Management

    Want to keep this site alive? Consider making a donation. Click here.

  9. #9
    Junior Member
    Join Date
    Feb 2008
    Posts
    5

    Default

    I have tried with a print statement in both post javascript and in the javascript section, but nothing is printed. Why does not the javascript trigger?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts