Tag Archives: fields

Showing users’ profile pictures in a SharePoint list

Special thanks to Joann for the question!

A common use case is to have a list of people in a list in SharePoint, maybe they’re members of a project, contacts for a department, your favorite people to talk to, whatever it may be, you have a list. This example is a listing of my teammates:

slalom people list

Now I’d like to spice it up a little and see their pretty little faces. In my example, I’m just using the Title field to store their names (well, the Title field renamed to Name, regardless, same scenario). This won’y fly. We need to add a people picker to the list. I added one called Account Details. You could name yours Photo, Pic, Face, etc.

Add a people picker to the list, and add the correct values:sharepoint list with names

You can edit this view in Quick Edit mode, and copy/paste the Name column into the Account Details column.

Now let’s configure it to show their picture! (yes you could’ve done this with the above step, but for illustration purposes I add more steps)

When you edit the People Picker Field, check out the Show Field property.

edit people picker

See the few options at the bottom? Picture Only, select one. In my example, I selected 72×72

people pictures in sharepoint

BLAM! Profile pictures!!

Now I’ll let my team know I’m sharing their pretty faces.

‘Til next time, Happy SharePointing!

Advertisements

SharePoint 2013 Script: Hide or Disable your fields

This one has been on my list for a while. I’ve used a collection of JavaScript methods to help streamline customizing forms in lists. I have created and compiled this little collection starting probably 5-6 years ago, and over time I’m constantly updating, tweaking, enhancing it, especially more so as of late working with Office 365.

I have a lightweight JavaScript file which allows you to hide or disable (set to read-only) fields in a new or edit form. It’s pretty basic but is a big value add. Also, you can set a field to read-only for only certain groups, meanwhile allowing other groups to edit the field. You can also hide a field completely, as well as hide a field and only show it for certain groups. Pretty sweet right?

UPDATED 2/28/15 to fix a few bugs as noted in the comments.

UPDATED 10/22/15 to fix disableWithAllowance and people pickers.

UPDATED 10/23/15 to fix disable and disableWithAllowance and metadata fields.

UPDATED 5/24/16 to fix issue with disabling Lookup Fields, now will show correct value.

UPDATED 8/1/2016 to fix issue with disabling choice fields as radio buttons, now will show the single selected value.

The script is here: download from CodePlex.com.

How to use it

Include the script along with jQuery on your page. Ideally, throw this nugget into your master page and you can use it anywhere in your site.

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" type="text/javascript"></script>
<script src="/SiteAssets/Lozzi.Fields.js" type="text/javascript"></script>

Once that’s in, get using it! It’s really simple, I threw this on my new form for my task list:

<script type="text/javascript">
 $(document).ready(function(){
  ExecuteOrDelayUntilScriptLoaded(function(){
   Lozzi.Fields.disableWithAllowance("Start Date", ["Project Managers"]);
   Lozzi.Fields.disable("Task Status");
   Lozzi.Fields.hide("% Complete");
  },"sp.js");
 });
</script>

This will change our New form for a typical task, from:

New SharePoint Task Form

to

New Task Form with Hidden Disabled Fields

See the difference? It’s subtle, but when working with end users, it can provide a huge benefit to help streamlining your business flow.

From here, you could have the edit form disable or hide a lot of the fields for normal users, only allowing your Project Managers, or if this is a support request list, your Support Team access to modify fields as needed. The options are endless.

More details

Lozzi.Fields.disable(fieldname)

Simply disables the field, for all users. It hides all controls in the field and displays the value instead.

Lozzi.Fields.disableWithAllowance(fieldname, groups)

Disables the field, but enables it for the users in the groups specified. Also, Site Collection Administrators are included automatically, so they can always edit the field. You can send the groups in an array, like [“Group One”, “Group Two”].

Lozzi.Fields.hide(fieldname)

Simply hides the field, for all users.

Lozzi.Fields.hideWithAllowance(fieldname, groups)

Hides the field, but shows it for the users in the groups specified. Also, Site Collection Administrators are included automatically, so they can always edit the field. You can send the groups in an array, like [“Group One”, “Group Two”].

Some other important notes

  • Currently, this script does not work on list views, meaning a user could edit the data in datasheet/quick edit view.
  • This script should work just as well on SharePoint 2010 if you so desire.

Download this script here: download from CodePlex.com.

Til next time, Happy SharePointing!

Use PowerShell to manipulate the values of a SharePoint choice field.

Thanks to Knoots for suggesting the idea for this post, from a comment on Using PowerShell to play with SharePoint Items.

Using PowerShell, we’re going to walk through handling a Choice field in a list. Specifically, this is a calendar list using the Category field. This may come in handy if you want to automate changing the values from another data source that BCS can’t connect to, or is too much work to get it to connect. I always prefer using SharePoint’s features, but sometimes we need to stretch it to make it work.

As a heads up, if you remove a value that someone has used in their item, the value will remain in the item UNTIL they come back in to edit the item. Since the value no longer exists in the option list, their value will be lost. However, if you have the option enabled on the field to specify their own value, then the previous value will be saved there.

Let’s get to it, open SharePoint 2010 Management Shell

$web = get-spweb http://site/web
$list = $web.lists["Calendar"]
$list

I like to run the $list just to ensure we have the list properly. Errors aren’t always displayed in PowerShell. Running $list should return the list name.

$choice = $list.fields["Category"]
$choice.choices

Again, make sure we have the right field, calling $choice.choices will list all of the current values. The Choices property is a StringCollection, so use typical commands to add/remove items.

Important. If you’re going to clear items then add items, or after any .update(), you’ll need to get the field again (type in $choice = $list.fields[“Category”] again) to access the new values properly.

remove all items

$choice.choices.clear()
$choice.update()

remove one item

$choice.choices.remove("Name")
$choice.update()

(remember get the field again to add items after clearing it)

add an array of choices

$choiceArray = @("Meeting","Work Hours","Business","Holiday","Get-together")
$choice.choices.addrange($choiceArray)
$choice.update()

add one at a time

$choice.choices.add("Name")
$choice.choices.add("Name Of Another")
$choice.update()

Happy SharePointing!

Creating an item detail dashboard view of your joined lists in SharePoint 2010

Thanks to Stan for suggesting the idea for this post, by leaving a comment here.

Our goal here is to take your joined lists and display them on a single page, so you can effectively review an item and its associated information. This is a useful task for creating views of projects with many tasks, milestones, documents, or customers with contacts, documents, or products with updates, documentation, downloads. Really, anywhere a list that is linked (via a lookup field) to another list, this can be applied.

First, let’s assume the following: we have a parent list, and a few daughter lists which have lookup fields to the parent list.

Parent and Daughter Lists

Simple enough. In my example here, I am going to use a project theme. I have a Projects list, a Tasks list, and an Issues list.

Starting with the parent list, first let’s disable the popup dialog option. We can’t edit the pages in a dialog window, plus you’ll want a nice full page to view all your info. Go to the parent list, click List in ribbon > List Settings > Advanced settings. At the bottom of the page, Select No under Launch Forms in Dialog. Click OK.

Browse back to your project list and select one of your projects. You should see the nice generic page view.

Press Site Actions in the top right, then select Edit Page. The page will switch to edit mode. Now go ahead and add your lists you wish to join. In my case, I am going to add Tasks and Issues. Your new web parts will be added to the top of the page. Make sure to drag your web parts down so your project details remains at the top.

Adding web parts to project display page

Once your web parts are added, edit each web part and set the Chrome Type (under Appearance) to Title and Border or Title Only, your choice. Make sure to click OK at the bottom of the edit web part panel to save your changes.

While we’re still in edit page mode, click the web part edit menu for your first web part (same place you went to edit the web part) and select Connections > Get Filter Values From > Projects.

Add the connection for the web part

A new dialog will appear.

Web part connections dialog

For the Provider Field Name, select ID. For the Consumer Field Name, select the  lookup field, Project. Click Finish.

Create the web part connection

Your web part will be reloaded and filtered based on your project.

Filtered connection web part

Perform these same connection steps for the other web parts on your page.

When you’re done, press Page ribbon, then Stop Editing. That’s it!

As you click and view each project, your tasks and issues will automatically filter for the selected project. Pretty sweet eh?

.

Take it further!

  • Edit the display form in SharePoint designer to add 2 columns to your page, allowing you to put additional web parts to the right of the details as well.
  • Using color coded calendars, see my post here, you can create a calendar view of your tasks and projects, color coded based on status. Create a calendar view in each list, then when creating the color coded calendar, use these lists and views!
  • Create a calendar for your tasks, color coded based on status, and add another web part to the above page to include the calendar!

Happy SharePointing!