Dashboards & Visualizations

Autopopulate username field in a form

logginz85
Explorer

Hi All,

 

I've got a form being built in Splunk Enterprise, its used as a lookup table so we can see if there is a known issue with a host etc...

logginz85_0-1613123662322.png

I use the issue field to have a drop down option, and the host and IP are manually input. 

What I'd like is for the "added by" field to be automatically populated with the signed in users ID/name/Username etc...This is for audit purposes mainly. 

I've looked around and can't seem to find out how to do this. 

Any/all help is greatly appreciated.

Labels (3)
Tags (3)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust
    <input type="text" token="user">
      <label>User name</label>
      <default>$env:user$</default>
    </input>

View solution in original post

logginz85
Explorer

I've got it. The idea was to have the username field auto-populated and to be read only so as to keep a record of which user submitted the item on the form. 
I thought of having it as a box that would read the $env:user$  field, then pulling that to a table to be displayed underneath,

The issue was that if the username field pulls $env:user$, the user could simply edit that field to another users details.

Got round it by instead of pulling to the form box, then going to table, just pulling straight to table.


Thank you greatly for your help. That really helped.

0 Karma

logginz85
Explorer

that a fair point, I'd like the field to be used to capture whoever submitted the option in the form, but it doesnt need to be displayed I guess.

As such, if I just hid the field but retained all the features, it would capture the env:user information but then not leave it open to be edited

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Yes, and this can be done with the depends attribute

ITWhisperer
SplunkTrust
SplunkTrust
    <input type="text" token="user">
      <label>User name</label>
      <default>$env:user$</default>
    </input>

logginz85
Explorer

That's amazing, so simple. Now how can I set it so that field cant be changed by the user too?

Tags (1)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

If you don't want the user to change it, why is it on the form in the first place?

You can add some style to prevent clicking on field, but if you want to disable it completely i.e. prevent tabbing to it as well, you will probably need to resort to javascript.

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

[Puzzles] Solve, Learn, Repeat: Matching cron expressions

This puzzle (first published here) is based on matching timestamps to cron expressions.All the timestamps ...

Design, Compete, Win: Submit Your Best Splunk Dashboards for a .conf26 Pass

Hello Splunkers,  We’re excited to kick off a Splunk Dashboard contest! We know that dashboards are a primary ...

May 2026 Splunk Expert Sessions: Security & Observability

Level Up Your Operations: May 2026 Splunk Expert Sessions Whether you are refining your security posture or ...