Dashboards & Visualizations

Get current logged in user's Email Address in Javascript SDK

cboulware
Engager

I'm attempting to get the current logged in user's email address from the Javascript SDK to pass to a js variable. I can get the current logged in Username, however the configKey values don't seem to exist in this docs article for getConfigValue, so I'm not sure what value to use for email address
https://docs.splunk.com/Documentation/Splunk/6.6.5/ModuleRef/Splunk.util#Parameters_8

Does anybody have the configKey value for the email address for the user in the JavaScript SDK? Or even an explanation for all of the options for configKey under getConfigValue?

Here's the code I'm trying:

require(["underscore","jquery","splunkjs/mvc","splunkjs/mvc/utils","splunkjs/mvc/simplexml/ready!"],
            function(_,$,mvc,utils) {
                    var username =  Splunk.util.getConfigValue("USERNAME").toLowerCase() 
                    var email = Splunk.util.getConfigValue("email")
            });
0 Karma

paramagurukarth
Builder

Please try this..

require(["underscore","jquery","splunkjs/mvc","splunkjs/mvc/simplexml/ready!"],
    function(_,$,mvc) {
        myService = splunkjs.mvc.createService();
        myService.currentUser().then(function(){
            alert(JSON.parse(arguments[0]).entry[0].content.email);
        });        
 });
0 Karma

niketn
Legend

@cboulware, first off Advanced XML is deprecated.

Secondly, the default environment tokens are available in Splunk ( Splunk Enterprise 6.5 and above ) which capture details like current User Name current App Name and event current user email. You do not need JavaScript as the same will be available directly in Simple XML $env:user_email$. You can also check out the Splunk Dashboard Examples App which has Default Environment Tokens example to showcase the same.

Refer to documentation: https://docs.splunk.com/Documentation/Splunk/latest/Viz/tokens#Use_global_tokens_to_access_environme...

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

cboulware
Engager

Yes, I'm aware that Advanced XML is depreciated, and I'm also aware of the global environmental tokens. However in this script I'm dispatching a oneshot search using the Javascript SDK, and I need to have the current user's email address.

I guess I can enable tokenization in my search and pass a global token, I was just wondering if there was some documentation on parts of the Javascript SDK that don't seem to be there, mainly what values you can use for configKey in the above linked doc article.

0 Karma

niketn
Legend

@cboulware, since your question is not answered, I have converted my answer to comment. So that this flags as unanswered meanwhile I try to find the details you are looking for.

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
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 ...