Friday, 28 April 2017

InfoPath Form: How to populate field on form load based on current user?


List One: Contains Account ID of the users and other fields.
List Two: Has the info-path form.

Customize List Two in InfoPath form:

Step 1. Create a connection to List One. Uncheck below option:

  • Store a copy of the data..
  • Automatically retrieve the data..
Step 2. Add a new rule under Form Load without any condition. Add 3 actions:
  1. Set a field's value:  Set the query field value for the above connection to filter the list item from List One. You can use userName() function to assign the value.
  2. Query using a data connection: Query for data from the above connection
  3. Set a field's value: Get the value from the data field  from the connection string and assign it to the form's field.

Wednesday, 26 April 2017

How to use SharePoint People Editor?


Designer:

<SharePoint:PeopleEditor ID="peopelID" runat="server" Width="350px" SelectionSet="User"
  MaximumEntities="1" MultiSelect="false" AllowEmpty="false" DoPostBackOnResolve="true"
   ErrorMessage="Type and press the enter key." ValidatorEnabled="true" ForeColor="Blue" >

</SharePoint:PeopleEditor>

Code:

To check if the control contains value:

if (peopelID.ResolvedEntities.Count > 0)

                {Do something...}

To clear the control:

peopelID.CommaSeparatedAccounts = null;

To read value:

PickerEntity picker = (PickerEntity)peopelID.ResolvedEntities[0];

Hashtable hstEntityData = picker.EntityData;

strWorkEmail = Convert.ToString(hstEntityData["Email"]);


CSS:

The control may look different based on the master page being used. So, you may need to use browser's developer tools to look for the style(s) to be changed.