AIOps

AIOps

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.


#ITAutomation
#AIOps
#CloudPakforAIOps
#AIOps

 View Only
Expand all | Collapse all

Dash Webgui tool function

  • 1.  Dash Webgui tool function

    Posted Sun November 30, 2025 10:17 PM

    Hi, we have a requirement to create a tool that will invoke javascript but also need it to execute SQL as well. We cannot seem to get this to work. 

    Example 

    script(foreach="true",language="JavaScript")
      {

    some code 

    if (x=1) {

    }

    else {

    sql(foreach="true",url="$(SERVER)/_tb37b/ael/Tool/Controller")
      {
        structure
        {
          text(data="update alerts.status set Location='")
          variable(name="username")
          text(data=");\u000d\n")
        }
      }

    }

    Any ideas on how we can get the above to work? 

    And once this is created manually, it can't be pulled in via the Dash Admin Tools function and edited because it will only save the SQL or Javascript part, depending on what tab is open when you click save. 



    ------------------------------
    Prem Sahota
    ------------------------------


  • 2.  RE: Dash Webgui tool function

    Posted Mon December 01, 2025 06:43 AM

    Hi Prem,

    tools are either/or - you can't combine SQL and Javascript.

    And given that the javascript-Tool runs in the user's browser, it doesn't have any access to the ObjectServer.

    Not sure what you need to achieve - if you need javascript functions in the user's browser and want to modify the event, then one way I can think of is to launch a cgi-script from the javascript-Tool. The cgi then could modify the event via nco_sql. Not at all ideal, but would work.

    If you just need to run different SQLs based on a variable x, consider adding the variable to the update's where clause (I'm using Severity instead of your x in the example):

    update alerts.status set Location='%username' where Serial in ( $selected_rows.Serial ) and Severity < 3;
    update alerts.status set Customer='%username' where Serial in ( $selected_rows.Serial ) and Severity >=3;

    If you need the user to enter the "x" value you can even use a prompt to retrieve the info from the user.

    HTH,

    Michael



    ------------------------------
    Michael Troitzsch
    Solution Architect
    DICOS GmbH
    Darmstadt
    ------------------------------



  • 3.  RE: Dash Webgui tool function

    Posted Wed December 03, 2025 11:19 AM

    Unclassified | Non classifié


     

    The javascript calling a cgi-script may be the best option for us. Can javascript call a script locally on the server? Can anyone provide an example on how to call a local script from within Javascript.






  • 4.  RE: Dash Webgui tool function

    Posted Tue December 02, 2025 03:12 AM

    or you could your code in an impact policy 
    do your javascript and then do a eventenrichment in the same policy

    and have a simple http call to to restapi to launch it..
    https://www.ibm.com/docs/en/tivoli-netcoolimpact/7.1.0?topic=servers-accessing-policies-remotely-using-rest-api

    if you have impact that is :-)



    ------------------------------
    mario schuerewegen
    IBM
    Brussels
    ------------------------------



  • 5.  RE: Dash Webgui tool function

    Posted Wed December 03, 2025 10:51 AM
    To add logic or developments, for example in Java, you must use Impact, create the project, policy, and service, then create the automation from AIOPS so that when it detects the rule, it calls the Impact automation. Currently, AIOPS has limitations in logic and rules, unlike what could be done in Omnibus. Another possibility is to have a Linux server, create the integration via SSH, and generate the programs/scripts to call and then execute remotely. The third option is to integrate an Ansible server and call the automation.

    Regards





  • 6.  RE: Dash Webgui tool function

    Posted Wed December 03, 2025 10:55 AM

    Saury.  its a webgui question  :-)  so no aiops..  but NOI



    ------------------------------
    mario schuerewegen
    IBM
    Brussels
    ------------------------------



  • 7.  RE: Dash Webgui tool function

    Posted Thu December 04, 2025 10:30 AM

    For Omnibus, you must create the tool and within the tool call the script, which must be on the Omnibus server. The tool sends the script parameters and the script calls the Java or Python. Another option is to use Impact and create an operator view so that when you run it from the menu, the operator view opens.

    If you'd like, you can give me an example of what you want to do so I can give you some guidance.

    Regards!





  • 8.  RE: Dash Webgui tool function

    Posted Thu December 04, 2025 10:36 AM

    Unclassified | Non classifié


     

    Hi, the tool has to be created in Dash as that is where the Operators initiate any action against an event by right-clicking and then selecting the desired tool to be executed.

     






  • 9.  RE: Dash Webgui tool function

    Posted Tue December 30, 2025 11:46 AM

    Hi Prem,

    This issue is that the Web GUI Tool definition doesn't support nesting an sql block directly inside a script block like that. The Tool Editor forces you to choose a single type (Script, SQL, CGI, etc.), which is why it strips out the 'other' part when you save.

    To get this to work, you should create a Script Tool (pure JavaScript) and use an AJAX request to execute the SQL update when your condition is met. You can do this by calling the ObjectServer REST API (OSLC) or the internal standard REST interface.

    Here is an example of how to structure the Script Tool to do this:

    // 1. Perform your Client-Side Logic
    var x = 1; // Your logic here
    var serial = row.Serial; // Get data from the selected row
    
    if (x == 1) {
        // Do nothing or handle the 'if' case
        console.log("Condition met, no update needed.");
    } 
    else {
        // 2. Prepare the SQL Update payload
        // Note: You typically use the OSLC/REST interface for this.
        // This example uses a standard XMLHttpRequest to hit the ObjectServer REST API
        
        var updateUrl = "/objectserver/restapi/alerts/status/" + serial;
        var payload = {
            "Location": username // Assuming 'username' is a variable you have defined
        };
    
        var xhr = new XMLHttpRequest();
        xhr.open("PATCH", updateUrl, true);
        xhr.setRequestHeader("Content-Type", "application/json");
        
        xhr.onreadystatechange = function() {
            if (xhr.readyState === 4) {
                if (xhr.status === 200 || xhr.status === 204) {
                    alert("Update successful");
                } else {
                    alert("Error updating: " + xhr.statusText);
                }
            }
        };
        
        xhr.send(JSON.stringify(payload));
    }
    


    ------------------------------
    Sheerbit SEO
    Sheerbit Technologies
    Bothell WA
    06174554551
    ------------------------------



  • 10.  RE: Dash Webgui tool function

    Posted Wed December 31, 2025 09:09 AM

    In Dash Webgui you cannot reliably mix JavaScript and SQL in the same tool block, which is why one part gets overwritten when saving. The recommended approach is to move the SQL logic to a server side controller or API and call it from JavaScript using an HTTP or AJAX request. Keep your conditional logic in JavaScript and trigger the SQL execution through the endpoint only when needed. This also ensures the tool can be safely edited and saved through Dash Admin Tools without losing code.



    ------------------------------
    Sau Harvey
    ------------------------------



  • 11.  RE: Dash Webgui tool function

    Posted Fri January 02, 2026 10:58 AM

    To make your script work, try separating the JavaScript and SQL execution logic: use JavaScript to handle conditions and PNW Prestige Exteriors then send an AJAX request to the server to execute the SQL query. This way, both parts will work together, and you can avoid issues with saving the script in Dash Admin Tools by treating them as distinct client-side and server-side components.



    ------------------------------
    raphael atkinson
    ------------------------------