Dashboards & Visualizations

Uncaught Error: Already have instance with id: in splunk

sumangala
Path Finder

Hello Splunkers,

I am showing some Splunk search data into table by 'TableElement' by splunk search id bind with 'TableElement' table manager id.

       search_query = new SearchManager({
            "id": search_id,
            "status_buckets": 0,
            "cancelOnUnload": true,
            "search": search_cmd,
            "latest_time": "$latest$",
            "earliest_time": "$earliest$",
            "app": utils.getCurrentApp(),
            "auto_cancel": 90,
            "preview": true,
            "runWhenTimeIsUndefined": false,
            "timeout": "10"
        }, {tokens: true});

        var element1 = new TableElement({
            "id": "element1",
            "drilldown": "row",
            "rowNumbers": "undefined",
            "wrap": "undefined",
            "managerid": search_id,
            "el": $('#element1')
        }, {tokens: true, tokenNamespace: "submitted"}).render();

Every time search called with new data. It has to be updated in table. But, getting Uncaught Error: Already have instance with id: in splunk error. I search possible solution for this, but didn't work out.
Can anyone tell how update table very time search is executed.

pbalbasm
Path Finder

Try to do this:

  • mvc.Components.revokeInstance("searchId");

Regards.

louismai
Path Finder

This works well. I place it in the teardown function:
teardown: function($container, rowData) {
var that = this;
that._tableView=null;
var search_idCell = _(rowData.cells).find(function (cell) {
return cell.field === 'Login Name';
});

            mvc.Components.revokeInstance(search_idCell.value);
    },
0 Karma

robertosegantin
Path Finder

Hi,
the solution that I've found is to create randomically the id.
This workaround can be used for all Splunk Javascript object
For example:

var epoch=(new Date).getTime();
var Dropdown = require("splunkjs/mvc/dropdownview");
var dropdown = new Dropdown({id: "Dropdown"+epoch,
default: "",
el: $("#mydiv")
}).render();
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...