Friday, February 21, 2014

SharePoint 101: Naming and Site Columns

I've been working with SharePoint 2010 for around 4 years on the front end, over that time I have found ways to make life easier for myself down the road. Here are a few simple but vital standards everyone should use when creating a site.

What: Naming

Where: Any time creating something new

When: Creating Site Columns, Content Types, Lists, Libraries, Pages, sub sites etc… keep the name as simple as possible. Ideally you want to use one word or a TLI (Three Letter Initials), do not use spaces, do not use long winded descriptions to start with.

Why: Because when you initially create something in SharePoint it uses that name to hardcode in a system variable. If you name a site Vacation Requests the URL for that site will have a %20 between the two words this is wasted space and can cause problems down the road. Same goes for Document Libraries, Lists and Tasks.

Even the default Document Library of a newly created site has this flaw in it.

If you create a column with a space or long winded name you can run into programing issues, I had this problem when inserting the Property Name in Custom Query Web Parts (CQWP) that I made for a custom user Dashboard (future post):

\<property name="CommonViewFields" Current_x0020_Status,choice;Start1,DateTime;

When I created "Current Status" with spaces and I ended up with 7 unnecessary characters, had I named it CurrentStatus, CStatus or CS (Status is a default) it would have been much simpler to figure out and code. Keep it simple.
 


What: Site Columns

Where: Site Actions > Site Settings > Site Columns
When: All the Time. Period. (ok most of the time)

Why: When you use site columns they can be reused on multiple list, sub sites and Content Types. This allows you to create a column once and use it over and over. When you update a site column you have the option of disseminate your update for all columns or just add it to other lists that are created afterwards.

Site Column setting:

This allows you to make a status like (again) Current Status and customize it for multiple lists, this is especially useful if you don't let users update them but rather workflow. Even if the list doesn't need "Pending Approval" you can still use the column and allow workflows and triggers select the necessary actions. 


How: to create a column under site Columns click on the Create at the top 

Chose the title (one word) then choose the Type:  

Once you select a specific column type you may not be able to switch it to another type so choose carefully as you may have to delete it later and start over.

Now you need to select where this will be found in the list under the Site Column List. If you are making multiple items that will be used for specific purposes then you should put them in a new custom group.

The rest should go under your new category or Custom to be easily found. 


Additional Columns Settings is where you want to spend some thought, especially since some columns NEED information here:

You can always come back and add remove options.

Now to use the newly made Column:

These can be added to a list or library and go to List Tools > List > List Settings >


Then Add from Existing Site Columns 

Now select your Group 

And select the Columns you want to add 

Now they show up as a column under the list. 


Sunday, February 16, 2014

InfoPath: Hidden Fields

I'm not a fan of having a form with fields that may not be used. Ideally, fields should only be displayed if They are needed. Take the new hire laptop request form, for example. Not all new hire laptops are shipped to the end user. Sometimes they are shipped to other offices or they stay here, in Seattle, to be picked up.

This means the Shipping Address remains empty. It leaves a rather large gap in the information on the form.


These fields should be hidden and should only show when the proper delivery method is chosen:

In SharePoint 2010, you need to use InfoPath to edit the form in order to hide unused fields. You can take the standard form and edit it to display exactly what you want to see.

Start by removing the fields you want hidden. (They will still be in the side bar.)
To add an Optional field, do the following:
  1. Open a new, separate InfoPath form.
  2. Drag the myFields folder from the Fields section on the right into the form itself.
  3. This creates a box called section (myFields)
  4. Click on the field to highlight and copy it.
  5. Move to your current list form and paste the field into both the name column and the field column. Example:

Unfortunately these fields are not editable because they have no association with the current form.
Right click on the field and select Change Binding…

Associate the section with the first field I'm planning on putting inside this area. In this case, it's the Shipping Address Primary Street Line.

Drag and drop the existing fields you wish to hide into the new section:

Then create a rule:
  1. Under the Home Ribbon select Manage Rules.
  2. Select the Section for editing.
  3. Create new rule: Formatting.
  4. Click on the Conditioning link (labeled None).
    1. The first drop down is the field you want the section to depend on.
    2. The second drop down is the logic statement .
    3. The third drop down is the dependancy for the section.
    4. There can be multiple dependancies and the option can be text or another fields choice. In this option, we chose "is not equal to" to "Ship".
  5. Select Hide this control, meaning when Delivery Method is not equal to Ship the field(s) will remain hidden.

InfoPath: Field Dependencies or Parent Child look ups

While collecting requirements for the new laptop deployment site I was asked if there was a way to allow different laptop model options other than the 4 standards we offer.
The idea was to allow each service line their own customized laptop options to prevent people from requesting laptops the service line does not have on hand or laptops they do not want their users to request.
The solution is to set up a set of dependencies that filter the information according to previous selections.
Let's start out with the list we want to submit:
Laptop Requests:
  1. Create a simple (requests) list with three columns all Single Line of Text entries
    1. User Name
    2. Region
    3. Service Lines
    4. Laptops
  2. Then create the secondary (Information) list where we will gather this information we want to have dependent on each other.
    1. Region
    2. Service Lines
    3. Laptops
Using Datasheet view, populate the information list with the dependencies. In this case it will have
  1. Regions:
    1. Asia
    2. Europe
    3. Americas
  2. Give each region at least two Service Lines
  3. Give each service line at least two Laptop options
Example: 

Now we will attach these data points to the Requests List. This change can be made by customizing the list with InfoPath

The list should look like this:

Currently each of these fields are simple text and do not actually reference anything and can be filled out with anything. We want to bind them to the other list and its options:
Under the Data ribbon go to Data Connections
  1. Add a connection
  2. Create a new Connection to:
    1. Receive Data
  3. SharePoint Library or List

  4. Enter your site if not already there
  5. Find your secondary list (requests)

  6. Select the columns you want to bring over from the secondary List

  7. Leave the next two sections as default and then finish
Now we need to associate each field on the list with it's the column information from the secondary list
  1. Right click on the region box and under Change Controls select Drop-Down List Box

  2. Right Click again and select properties at the bottom.
  3. Select Get Choices from an External data source, under Data Source select the Data connection you made earlier (Information)

  4. Under the entries tree select region and then check the box that says Show only entries with unique display names

  5. This will now display the three region options on the form


Repeat steps 1-3 for Service Line
  1. However when you go to select the entries value you will add a step
    1. Once you select Service Line then you will select Filter Data below.
    2. Add
    3. In specify Filter Conditions
      1. Select Region in the first drop down
      2. is equal to in the middle drop down
      3. Choose Select in a field or group for the last drop down
        1. Change the field to Main
        2. Then chose the Region Field
        3. OK all sub menus until you are back in the original properties menu
  1. Select "Show only entries with unique display names"
Now the Service line is option cannot be selected unless the Region field is completed
And it will only show service lines that are under the region you selected.

This same process can be applied to the laptop options by selecting the service line under the filter options