Disable a List Field When Adding/Editing in 2010

SharePoint 2010 now uses InfoPath 2010 forms for adding and editing list items. You can customize these forms to meet your needs which includes changing the order of the fields, removing fields and hiding fields for certain users. In this example I’ll show you how to disable a field if the user is not added to a custom security list. This allows you to control who has ability to maintain the data in a specific field.

  1. Create a new custom list called “Secure Users”
  2. Add a Person column called “User”
  3. Change the column to display the field called “User name”
  4. Go to your primary list where you want to disable the field and click “Customize Form” on the ribbon
  5. The following steps are in InfoPath 2010
  6. Add a new data source for the Secure Users custom list
  7. Add a Form Load rule to filter the Secure Users data source on the current user
    1. Add an Action Rule to “Set a field’s value”
    2. Select the User field in the list of queryFields for the Secure Users data source
    3. Set the value to the function userName()
    4. Add another rule to query the list with the new filter
  8. Add a rule to the appropriate controls you want disabled
    1. Select the field and add a new formatting rule
    2. Set condition – Select AccountID in the Secure Users dataFields
    3. Select “Number of occurrences of AccountID” in the “Select:” dropdown
    4. Select “is equal to” and enter zero as the value
    5. Select “Disable this control”
  9. Quick Publish the form and you’re done!

You’ve created a form that checks the Secure Users list for the current logged in user. If the user is not in the list the selected field will be disabled.

Advertisements