Site icon @WonderLaura

List Form Fields–Show/Hide For Certain People: Part 2

In this second post of the three part blog series, I will show how you can show or hide fields according to whether or not the currently logged in person is part of a certain SharePoint group.

This is a three part blog:

In this example, I have a task list, and there are only certain people who should be able to edit the task’s due date.  Others should be able to see it but not edit it. This concept is very similar to the concept in the previous blog post, there are just a few things different in the steps.

This solution in part 2 can be done with any enterprise version of SharePoint: MOSS, SharePoint 2010, even SharePoint Online with Office 365 (enterprise plans).

  1. Create a custom list on your site, just to keep a single item in, with a very simple purpose that will be apparent as we go.  I’ll call it “Single Item”.  Add one item to the list, just type anything in the Title field.
  2. Open SharePoint Designer.  In Lists and Libraries, open your task list.  In the Forms section on the right, click the New button.
  3. Call your new file EditCustom, pick Edit item form, and check the box to set as default.  Click OK.
  4. Click the name of your new EditCustom.aspx form to open it.
  5. Click your cursor inside the form on the screen somewhere, so that the contextual ribbon will show the appropriate options.  Click the Parameters button on the Options tab.
  6. Click the New Parameter button.  Call it the FilterParam, select Query String, and type Filter as the query string variable.  Click OK.  (side note: all those other 3 variables were already there, I didn’t add them)
  7. Select the Due Date field with your cursor:
  8. On the Options tab in the ribbon, click Conditional Formatting, and choose Show Content.
  9. On the Condition Criteria screen, click the Advanced button.
  10. Type $FilterParam!=”  then click OK and click OK again.  This means that if the task admin parameter is not blank, it will show the content you selected, which is the date editable field.
  11. With the cursor still in the Due Date right column, select the Due Date field in the Data Source Details pane on the right.  Click Insert Selected Fields As… choose Formatted… and choose DateTime.
  12. Now you’ll see a “read only” date on your form.  It’s time to create a rule that will show this field when the logged in person is not a task admin.  Note that with conditional formatting, you do have the ability to select an entire row if you want, and just show/hide the whole thing.
    Select the new date you just added to the form.  Click the Conditional Formatting button and choose Show Content.  Repeat steps 9 and 10, except this time don’t put an exclamation mark (!) in the formula.
  13. Save your changes.
  14. Click the F12 button on the keyboard to open the page in the browser.  Be sure to flip back over to SharePoint Designer and CLOSE that aspx form.
  15. In the browser, click the Page tab.  Click the Edit Page button.
  16. Click the big white section on the page that says Add a web part.  Add the Single Item list that you created at step 1.
  17. For the Single Item web part, in the Toolpane, expand the Advanced section. In the Target Audiences box, type or select the name of the group of people that you DO want to be able to edit the task due date. Click OK.
  18. Click the black arrow at the top right of the Task Admins web part, and choose Connections.  Choose Send Row of Data to, and choose your Task web part.
  19. Choose Get Parameters From, and click Configure.
  20. The Provider field name is “Title”, and the consumer is the FilterParam.  Click Finish.
  21. Now that the web parts are connected, and you’re seeing the editable Due Date field if you’re in the SharePoint group that you used in step 17, it’s time to hide the Single Item web part.  In the web part toolpane for Single Item, expand the Layout section.  Check the box next to Hidden, and click OK.
  22. On the page tab at the top, click Stop Editing.

Go ahead and test the solution.  Navigate to your Tasks list as you normally would, and Edit one of the tasks.  You’ll notice that if you’re in the list of task admins (or whatever SharePoint group you used at step 17), you’ll see the Due Date as editable.  Then, take yourself out of that SharePoint group, and then when you edit a task, you won’t be able to change the due date.

Technorati Tags: SharePoint,data view web parts,web parts,parameters,forms,fields,list form


Exit mobile version