Populate Dropdown OnLoad based on Username

S

Steve Z.

I have had a request to filter values for a dropdown list based on user when
Form loads.
I have built a Web Service, that accepts userId and returns Dataset.
I have read that i can get userid from Environment.UserName (yes I know i'll
have to raise security on my form to get this).
So my problem is getting the dropdown to populate based on the value i get
back from Environment.UserName. Any help would be great?

TIA
Stephen Zelonis
 
S

Sandeep

Hi Steve Z

Step 1 . Insert text box from taskpane controls.
Step 2 . Click on "tools" options and select "programing" and click "on load
Event" option.

Past this code in Onload event. Click on preview option in infopath form.

var wshShell = new ActiveXObject("Wscript.Shell");
var wshEnv = wshShell.Environment("Process");
var username = wshEnv.Item("UserName");
XDocument.DOM.selectSingleNode("/my:myFields/my:field1").text = username;

I hope this will help U
 
Top