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
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...