Dashboards & Visualizations

How to import the token value in the JavaScript in Simple XML?

kedjjang
Path Finder

alt text
Create a wish come test.js code to get the value of $ time_ok1.earliest $.

jeffland
SplunkTrust
SplunkTrust

Is your token named time_ok1?

0 Karma

joao_amorim
Communicator

No i have the token with other name but i don't know why the only one that doesn't work is the tokens of the time input, the others work fine....

0 Karma

jeffland
SplunkTrust
SplunkTrust

That's because the time tokens are special, they are objects containing two fields: earliest and latest (as already stated in the answer above). You should be able to get them with token_name.earliest or token_name.earliest_time, or as kedjjang mentioned with your_token.optionsdefault.earliest_time.

0 Karma

joao_amorim
Communicator

I already posted 5 times the answer but it wasn't posting it here i don't know why.
The answer is in the next comment

0 Karma

joao_amorim
Communicator

I answered already but the answer did was posted here

0 Karma

joao_amorim
Communicator

When i open the dashboard the only tokens that don't work are these related to time inputs because the others work fine. As I have the tokens set are working but just after i change the time input to other date. The first time the dashboard loads, the get of the earliest and latest gives undefined

0 Karma

joao_amorim
Communicator

Ok i tried only the token_name.earliest and it works but only after i change the time, because the first time that i open the dashboard it can't get the value of the token_name.earliest.
When you open the dashboard the value of earliest and latest of the time token are undefined and I don't know why cause all the other are working correctly.

0 Karma

kedjjang
Path Finder

Thank you.

Fixed with respect to this issue.

var tokens = mvc.Components.getInstance ("kang");
var defaultEtime = tokens.options.default.earliest_time;

0 Karma
Get Updates on the Splunk Community!

Unlock Database Monitoring with Splunk Observability Cloud

  In today’s fast-paced digital landscape, even minor database slowdowns can disrupt user experiences and ...

Purpose in Action: How Splunk Is Helping Power an Inclusive Future for All

At Cisco, purpose isn’t a tagline—it’s a commitment. Cisco’s FY25 Purpose Report outlines how the company is ...

[Upcoming Webinar] Demo Day: Transforming IT Operations with Splunk

Join us for a live Demo Day at the Cisco Store on January 21st 10:00am - 11:00am PST In the fast-paced world ...