userName() returning different values for infopath 2010 form filler and web form [closed]

StackOverflow https://stackoverflow.com/questions/15782759

  •  31-03-2022
  •  | 
  •  

Question

I'm writing a form which uses userName() to get the user name and put it into a text box at form load if its not blank,this returns firstName.lastName when the form is filled by infopath form filler. However if the form is filled from a web form it returns some random characters followed by domain/firstName.lastName

Ideally I want the same from both and for it to be just firstName Lastname or FirstName.lastName

Currently I'm working around this by not enabling web forms but need to fix it as a lot of users don't have Infopath form filler.

I also need to fix this at the time of the rule being called as I use the field to form part of the file name also.

Any ideas on how to overcome this?

Était-ce utile?

La solution

SharePoint loves to add random characters at the start of a username. I assume you are seeing something like "#15;" or something along those lines?

To fix this it would be done easiest in the code behind where you simply grab the field that is bound to the user name textbox and it will return a string.

Pretty much you have to parse the string, find the str.IndexOf('/') and create a substring starting at that index all the way to length -1. Then you can do a str.Replace('.', ' ') to change the period to a space.

Good luck!

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top