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
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 ...