Viser opslag med etiketten Infopath. Vis alle opslag
Viser opslag med etiketten Infopath. Vis alle opslag

mandag den 2. marts 2009

InfoPath - Get the current user without writing code

  1. With InfoPath opened go to Tools > Data Connections, and click 'add...' to add a new data connection to the form. This opens up the Data Connection Wizard.
  2. We want to receive data from the WS about the current user, so choose receive data' and click next.
  3. Our data source is a WS so choose 'Web Service' and next.
  4. Now you will have to point the wizard to the WS. Type an address similar to this: http://ServerName/_vti_bin/UserProfileService.asmx and click next.
  5. Here you get a list of all methods for that WS, choose GetUserProfileByName and click next.
  6. In this screen you can specify what parameters are sent to the method, we are relying on the method's ability to return the current user name if no value is passed to it, so we will leave this as is (no value is passed to the method) and click next.
  7. Click next and make sure 'Automatically retrieve data when form is opened' is checked.
  8. Finish the wizard.

The GetProfileByName method returns a PropertyData array. You can think of it as a repeating table of name and value pairs. So Now that you have a data connection that can get the current users, you can use it values. In this example I will show the user's first name in a textbox.

  1. Add a textbox to the form.
  2. Go to the first textbox's properties (double click it).
  3. In the 'Default Value' part, click the 'fx' button next to the 'Value' field. this opens up the formula builder dialog.
  4. Click 'Insert field or group'.
  5. In the data sources drop down, choose the GetUserProfileByName data source.
  6. Expand all groups under the 'dataFields' group, and choose the 'value' field. Don't click OK yet!
  7. With data 'value' field selected, click the 'Filter Data...' button and 'Add...'.
  8. In the first drop down (value) select 'Select a field or group...' and choose the 'Name' field under the 'PropertyData' group.
  9. Leave the middle drop down as is ('is equal to') and in the last drop down choose 'type a text...'.
  10. This is the part where you specify which property to put in the textbox. As we said the method returns multiple properties about the user. For this textbox we want to put the user's first name in, so type 'FirstName' (this is case sensitive!). I have included the property list you can use here (just below), so if you want some other property, just type its name instead.
  11. That's it, all we have to do is to confirm everything so Click 'OK' for every open dialog box until you are back in the design mode.
  12. click 'Preview' and see the wonder!
  13. If you want more details repeat steps 1-11 and enter different property names in step 10.

Finally, as I Promised, here is the complete list of default profile properties get returned by the userprofileservice. I think they are pretty self explained:
UserProfile_GUID
AccountName
FirstName
LastName
PreferredName
WorkPhone
Office
Department
Title
Manager
AboutMe
PersonalSpace
PictureURL
UserName
QuickLinks
WebSite
PublicSiteRedirect
SPS-Dotted-line
SPS-Peers
SPS-Responsibility
SPS-Skills
SPS-PastProjects
SPS-Interests
SPS-School
SPS-SipAddress
SPS-Birthday
SPS-MySiteUpgrade
SPS-DontSuggestList
SPS-ProxyAddresses
SPS-HireDate
SPS-LastColleagueAdded
SPS-OWAUrl
SPS-ResourceAccountName
SPS-MasterAccountName
Assistant
WorkEmail
CellPhone
Fax
HomePhone

fredag den 17. oktober 2008

URL parameter til InfoPath Form Services

Nå man skal udfylde en infopath web formular i sharepoint, sker der normalt ved at laver en nyt dokument i det dokumentbiblotek hvor formularen er tilknyttet. Men der findes en bedre metode, nemlig vil at lave et link som brugerne kan klikke på. Fordelen ved dette er at brugerne ikke behøves at vide noget om det dokumentbiblotek hvor formularerne bliver gemt, og måske skal i ikke engang have adgang til det.

Ok hvordan opbygger med så den url, her et et eks.
http://server/site1/formularliste/_layouts/FormServer.aspx?xsnLocation=http://server/site1/formularliste/Forms/template.xsn&SaveLocation=http://server/site1/formularliste&Source=http://server/site1/formularliste&DefaultItemOpen=1

1. del
http://server/site1/formularliste/_layouts/FormServer.aspx beskriver hvor er
FormServeren.

2. del
xsnLocation=http://server/site1/formularliste/Forms/template.xsn beskriver hvor infopath templaten er placeret.

3. del SaveLocation=http://server/site1/formularliste beskriver hvor skal formularen gemmes, hvis der er en SAVE knap på formularen. Det giver god mening at undvære denne parameter, da man normalt inden i infopath formularen kontrollere hvor den skal gemmes . via en submit forbindelse.

4. del Source=http://server/site1/formularliste beskriver hvor skal brugeren sendes hen, når formularen lukkes.

5. del DefaultItemOpen=1 beskriver at formularen skal åbnes i en browser.

Se i øvrigt her:


Parameter Name

Description

Allowed Values

XmlLocation

Used to open an existing form. The XmlLocation and XsnLocation properties are mutually exclusive; specifying values for both parameters will result in an error.

A valid URL to a form file (.xml) in the same site collection.

XsnLocation

Used to open a new form based on a form template. If an XsnLocation is specified in a URL using FormServer.aspx, a SaveLocation should also be specified if the Save and Save As buttons need to be displayed. The Source parameter should also be specified or the message "The form has been closed" will appear when the user closes the form. The XmlLocation and XsnLocation properties are mutually exclusive; specifying values for both parameters will result in an error.

A valid URL to a form template file (.xsn) published on the same site collection.

OpenIn

  • If a Source query parameter is specified, the default value is Browser.

  • If XmlLocation is specified, the default value is the setting used in the library.

  • If only XsnLocation is specified, the default value is PreferClient.

  • If Mobile is specified, the form will be redirected to the MobileFormServer.aspx page for rendering. The form template must be enabled for mobile support or an error message will be returned.

  • Browser

  • Client

  • PreferClient

  • Mobile

Source

The location to which the user will be redirected when the form is closed. The URL must be in the same site collection or an error will be returned.

A valid URL in the same site collection as the form.

Options

DisableSave is the only allowed value. It hides the Save and Save As buttons and disables saving the form when it is rendered in the browser.

DisableSave

SaveLocation

A Save As dialog box is displayed prompting the user for a filename, and then it is saved in the specified folder. An error is returned if the specified folder does not exist.

Any valid folder location on the site collection.

NoRedirect

Does not redirect to FormServer.aspx for client detection or rendering in the browser. Default value is false. If true and an XmlLocation or XsnLocation is specified, a File Download dialog is displayed when using Internet Explorer.

  • true

  • false (default)

DefaultItemOpen

The OpenIn parameter should be used instead, and overrides the DefaultItemOpen parameter value. A value of 0 indicates that the request is from a document library and the InfoPath client was not detected. A value of 1 indicates that the request is from a document or form library that has the Display as a Web page setting.

  • 0

  • 1


http://msdn.microsoft.com/en-us/library/ms772417.aspx


InfoPath Web form "inden" for sharepoint

Når Infopath Form Services på en Sharepoint server åbner web formularen, sker dette i et "blank" vindue, dvs. uden sharepoint udsende. Hvis du gerne vil åbne en formular "inden" for sharepoint i en webpart, er her en artikkel som beskriver en at de metoder du kan bruge: http://elczara.spaces.live.com/blog/cns!554EC06D366AC9D5!186.entry

InfoPath - visual how to

På msdn kan du finde en del gode "how tos" - her er dem der vedrører InfoPath:

Adding User Information from Active Directory Domain Services to InfoPath 2007 Forms
Creating and Editing Custom Document Information Panels in InfoPath 2007
Designing InfoPath 2007 Forms for Mobile Web Browsers
Publishing InfoPath 2007 Form Templates to Servers Running InfoPath Forms Services
Pulling CRM Data into InfoPath 2007 Browser Forms