Dashboards & Visualizations

Writing Out to beforeLabel on SingleValue

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

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

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

Champion

No worries, glad it helped 🙂

0 Karma

Path Finder

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

0 Karma
State of Splunk Careers

Access the Splunk Careers Report to see real data that shows how Splunk mastery increases your value and job satisfaction.

Find out what your skills are worth!