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!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...