Showing username, but working with account name in forms

Hi,

I have an InfoPath form where I load data from a list. For every employee there is a dataset with detail information for him. In the form I display the username and the data and save it. A workflow now takes this data and works with it.

It's all fine as long as I display the account name in the list and take this in the form, because then I have this in the form xml.

But when I display the username, only this one is saved to the XML. And it's really difficult to get the correct user, because (as you know) the username itself is not unique. So I need the account name ...

Is there a way to display the username, but save the account name? Is there a way in the list, maybe to have a field with the accountname and another field for the view, where you see the username?

[819 byte] By [Uwe82] at [2008-1-1]
# 1

Maybe I don't understand the question.

You can easily show one in a visible field, and store the other in a hidden field. Is that what you're after?

*edit*

If you're talking about a dropdownlist in particular, you can put the account name in the value part of the list, and the username in the display part of the list. When I did this, I ended up actually using a pipe-delimited concatenation of the two fields in the value and parsing it out, because I couldn't figure out how to get the display text out of the dropdown. Of course if you don't need to grab the display text to store it, then you should be fine.

SheikYerbouti at 2007-9-12 > top of Msdn Tech,SharePoint Products and Technologies,SharePoint - InfoPath Forms Services...
# 2

It's something like that, or a better solution.

When I create a form and collect data from a list, I get the values that are displayed. So when I have a user field in my list and display the full name, I get the full name in my InfoPath form.

But the problem then is, that I have this name in my workflow and have no exact match to a user account. For this, I need the account name. But displaying something like domain\username in the list is not really pretty, thats the problem. Same in the infopath form.

In my opinion, I need 2 fields, one for displaying stuff and one for the data itself. But I need them to be connected. In the edit form, I will then use the data field, for managing the account data and the other field should display the displayname of the user for my views.

It's difficult to describe my problem ... maybe I'll write a better description this week ...

Uwe82 at 2007-9-12 > top of Msdn Tech,SharePoint Products and Technologies,SharePoint - InfoPath Forms Services...
# 3

Hi Uwe82...

It sounds like you're on the right track. You'll need a second field to store the user's account name on the form. Remember, that you can create a field for the form in the Data Source area and not have it actually displayed on your form. This way, you can reference that field on the form for your workflow.

I hope that helps.

JHMorris at 2007-9-12 > top of Msdn Tech,SharePoint Products and Technologies,SharePoint - InfoPath Forms Services...
# 4

Yes, that's also what I was thinking of. But the problem is to have the data in the list.

I need these two fields also in the list. One in the background, which output will be the account name and the other one for displaying the user's name. But how can I link these two together? I can use a computed field, or I can use a User field. But there is no way to have both, you know what I mean? I cannot use the value of the other field and treat it as a user field to display another value of the user.

The only way I see atm is to use event handlers, to fill the background field with the data of the displaying field when an item is added or updated ...

Uwe82 at 2007-9-12 > top of Msdn Tech,SharePoint Products and Technologies,SharePoint - InfoPath Forms Services...
# 5

I created a workaround for this problem now: I have a field "MitarbeiterInt" which shows the account name and is hidden, and a field Mitarbeiter, which is shown in all forms and displays the real name of the user.

Then I wrote an event handler and handled the ItemAdding- and ItemUpdating event, in which I filled MitarbeiterInt with the username of Mitarbeiter.

Those two fields are now used in my InfoPath form, the first (Internal field) for the data in the form and the second one for displaying the name.

It works this way, though it's a bit ... yeah, a workaround.

Uwe82 at 2007-9-12 > top of Msdn Tech,SharePoint Products and Technologies,SharePoint - InfoPath Forms Services...

SharePoint Products and Technologies

Site Classified