Auto select item in drop down based on user
-
31 iulie 2012 22:04
Greetings,
I'm attempting to have a drop-down list in an InfoPath 2010 form auto select a Team based on the user that opens the form. I have two lists in SharePoint 2010 with the following:
Teams: one column for Team (choice, site column). One team per row.
Staff: two columns, one is the User (type is Person or Group, displays 'User name'; the other is Team (choice, site column).
Staff are only in one team. I do not need the form to hide any other team choices, just auto select it based on a person's team membership.
Thanks in advance!
Toate mesajele
-
1 august 2012 07:39
Hi
In infopath you can get current user name by using userName() function.
Next, you need to filter data you want to see in dropdown by using i.e. "set value" action or default dropdown value option.
Also make sure that while you matching user name from userName() function to user name from you sp list,
that both values are small or upper cases. Info path will not match "User" = "user".
Below please see infopath filter example:
http://social.msdn.microsoft.com/Forums/en-US/sharepoint2010customization/thread/65dca59f-c2a3-40ec-abfa-74126b512099Regards, Marcin (Please mark as helpful or answered if it helps)
-
3 august 2012 19:02
Marcin,
Thanks. Admittedly I don't have the greatest of InfoPath skills (and our developer left last month), so my attempts are yielding the exact result I want.
If I set a filter on the Team field, where the condition is the user's Display Name (from the Staff list) = userName(), then I do get the Team filed set to the correct team, but no other options present themselves. I'm supposing this is where a Rule would come into play to choose, rather than set and exclude other options? I'll read your link further, but for now it's escaping me how to do so.
Thanks,
Bill
-
6 august 2012 07:26
Hi
Yes on form load you should use "Set Value As" rule and set desired value to "Team Field". If you use dropdown properties instead you will get fill filtered value which you don't want.
Regards, Marcin (Please mark as helpful or answered if it helps)
-
6 august 2012 08:07Moderator
Hi wjbova,
Do you mean you have a Team drop down control. When a user login the form, it will auto select the team which the user belongs to in the drop down control?
1. In Form loading event, Add a rule to set a field (let's named "user_team") = Team name (from staff list where user name = userName()). Then we have the team is user_team field.
2. Add a action rule to "user_team" field.
Set a field's value: team drop down field=user team field.
Then all selections still available in team drop down field, but it will select the team that current login user belongs to when form open.
Thanks & Regards,
EmirEmir Liu
TechNet Community Support
- Marcat ca răspuns de Entan MingMicrosoft Contingent Staff, Moderator 10 august 2012 08:20
-
6 august 2012 20:57
I've set up a form load rule (type Action) to "Set a field's value" using the following conditions:
- Field: ddlSupportTeam - this is the drop down that gets its data from the Team list
- Value: Insert Field or Group, selected the Team dataField from the Staff list
Interestingly, when I first tested it I got the desired result; properly selected team, with other options available. Now it only selects one specific team, no matter who the user.
-
7 august 2012 06:54
Hi
I would start debugging this using additional fields, step by step every which is compared point to different field to see that all the values matches.
Also if this is web-browser enabled form try to go to properties of the dropdown / field and under "Browser forms" tab select appropriate option.
Hope this helps.
Regards, Marcin (Please mark as helpful or answered if it helps)
- Marcat ca răspuns de Entan MingMicrosoft Contingent Staff, Moderator 10 august 2012 08:20