Dashboards & Visualizations

Writing Out to beforeLabel on SingleValue

Drainy
Champion

So at the moment there is some jquery I use which I believe @sideview posted some time ago, it begins with;

if (Splunk.Module.SingleValue) {
    Splunk.Module.SingleValue = $.klass(Splunk.Module.SingleValue, {
        renderResults: function($super, result) {

Now my problem is that I need to change the text to a link to another dashboard. If I use the linkView and linkSearch then it will pass a search through, I just want to link directly to another dashboard without using the view results link.

So, I decided to try and re-write the above to access the beforelabel but with little to no effect.
If anyone has any suggestions on how I could achieve this then I would be glad to hear it. I just need to do a text match on the contents of the beforeLabel and then assign a static URL to a custom dashboard for that text.

Tags (2)
1 Solution

Drainy
Champion

And below is the answer I eventually came up with after digging out the SingleValue module code 🙂 This code will look for a particular text match in your beforeLabel and apply a static link to it. You can extend this easily to add a link across the result and afterLabel too.

if (Splunk.Module.SingleValue) {
 Splunk.Module.SingleValue = $.klass(Splunk.Module.SingleValue, {
  renderResults: function($super, result) {
   var retVal = $super(result);
    if (this._before_label=="beforeLabel Text -") {
    $('.singleLabelBefore', this.container).html("<a href='dashboardtolinkto'>beforeLabel Text -</a>");
    } else if(this._before_label=="different beforeLabel Text -") {
     $('.singleLabelBefore', this.container).html("<a href='diffdashboard'>different beforeLabel Text -</a>");
    } 
    return retVal;
    }
});
}

View solution in original post

Drainy
Champion

And below is the answer I eventually came up with after digging out the SingleValue module code 🙂 This code will look for a particular text match in your beforeLabel and apply a static link to it. You can extend this easily to add a link across the result and afterLabel too.

if (Splunk.Module.SingleValue) {
 Splunk.Module.SingleValue = $.klass(Splunk.Module.SingleValue, {
  renderResults: function($super, result) {
   var retVal = $super(result);
    if (this._before_label=="beforeLabel Text -") {
    $('.singleLabelBefore', this.container).html("<a href='dashboardtolinkto'>beforeLabel Text -</a>");
    } else if(this._before_label=="different beforeLabel Text -") {
     $('.singleLabelBefore', this.container).html("<a href='diffdashboard'>different beforeLabel Text -</a>");
    } 
    return retVal;
    }
});
}

Drainy
Champion

No worries, glad it helped 🙂

0 Karma

606866581
Path Finder

Thanks for this!
Adding a link to a single value is unnecessarily difficult, you've been a great help

0 Karma
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 ...