Monday, July 29, 2013

SharePoint 2010 - Hidden Querystring options

Some commands to change the mode of a page your are on.


Add Web Parts \ Search ToolPaneView=3
Add Web Parts \ Browse ToolPaneView=2

View Mode mode=view
Edit Mode mode=edit

Personal Mode PageView=Personal
Shared Mode PageView=Shared



example newForm.aspx?ToolPaneView=2&PageView=Personal


AllItems.aspx?contents=1 will open Web Part Page Maintenance: AllItems




Friday, May 3, 2013

SharePoint 2010 Server rename - Cannot connect to configuration database error

Assumptions (not best practice): You have a standalone SharePoint 2010 farm installation.

Problem: Oh dear, you ran the stsadm renameserver command after you renamed the actual server name.  Now you getting the dreaded Cannot connect to the configuration database error.

Never fear, there is a solution to this and its relatively easy, its worked for me.

1. Create an alias from oldservername, to newservername in mssql configuration manager.  If you are using named instances for your SharePoint farm databases, setting up an alias for a named instance can be a bit tricky, but here is how its done http://bigjimindc.blogspot.com/2009/08/ms-sql-server-named-instances-and.html

2. Once the alias is done and is working, you will now be able to access the central administration.  Once in, go an update the alternate access mappings in central administration , then simply run the stsadm renameserver command again.  


stsadm -o renameserver -oldservername "oldserver" -newservername "newserver"

3. Now, remove the aliases (delete them)

4. Reboot server (if you can, else restart mssql and iis).

5. You should now have a working SharePoint farm again.


I believe you HAVE to run the stsadm renameserver command before you rename a actual servers name.  But sometimes you cannot do this and therefore my steps above should help you fix a "broken" SharePoint farm.  Well it did at least for me :-)


Thursday, April 25, 2013

SharePoint Designer 2013 - SharePoint 2013 Workflow

Enabling SharePoint 2013 Workflow in SharePoint Designer 2013.

By Default, SharePoint 2013 Workflow is not available in SharePoint Designer 2013, you need to install workflow manager first, then configure it.



Steps to follow:


  1. Install Workflow Manager Client http://go.microsoft.com/fwlink/p/?LinkID=268376
  2. After installation, if you are communicating with Workflow manager via http or https you may need to change the powershell cmdlet to suite.  In my case I was using it over HTTP, so the following cmdlet worked for me.  You can have a look for "Workflow Management Site" in IIS, to get the workflowhosturi.
Register-SPWorkflowService –SPSite "http://myserver/mysitecollection" –WorkflowHostUri "http://myserver:12291" –AllowOAuthHttp

After those steps, you should now have the SharePoint 2013 Workflow enabled.

To see more detail, have a look at this technet article. http://technet.microsoft.com/en-us/library/jj658588.aspx#section4

Wednesday, April 3, 2013

Get fields using Javascript Client Object Model


Using the Javascript Client Object Model, you can get values from a listitem. 

How to use the JSOM is described here Code Project

Title – SP.ListItem.get_item(‘Title‘);

ID – SP.ListItem.get_id();

Url -SP.ListItem.get_item(‘urlfieldname‘).get_url()

Description – SP.ListItem.get_item(‘descriptionfieldname‘).get_description();

Current Version – SP.ListItem.get_item(“_UIVersionString“);

Lookup field – SP.ListItem.get_item(‘LookupFieldName’).get_lookupValue(); // or get_lookupID();

Created By – SP.ListItem.get_item(“Author“).get_lookupValue();

Modified by – SP.ListItem.get_item(“Editor“).get_lookupValue();

Choice Field – SP.ListItem.get_item(‘ChoiceFieldName‘);

Created Date – SP.ListItem.get_item(“Created“);

Modified Date – SP.ListItem.get_item(“Modified“); -> case sensitive does not work with ‘modified’

File  – SP.ListItem.get_file();

File Versions -  File.get_versions();.

Content Type – SP.ListItem.get_contentType();

Parent List – SP.ListItem.get_parentList();

Note:  (‘LookupFieldName’).get_lookupValue() sometimes returns an array of data, especially when your lookup allows multiple values.
In that case you will need to iterate the array and get each value individually.

 SP.ListItem.get_item(‘LookupFieldName’)[0].get_lookupValue(); - this will get the first item in the array.

For Arrays:


       for(var i = 0; i < oListItem.get_item("LookupFieldName").length; i++)
{
     alert(oListItem.get_item("LookupFieldName")[i].get_lookupId()); // or get_lookupValue()






Friday, February 8, 2013

Calculated Column - Add x days to created date, excluding weekends.


Overview

Say a user creates a item in a list and they have 3 (working days) to to mark it as completed, how do we do this?

1. Create a new field in the list (calculated field of type date and time), lets call it "escalate date", then using this formula.

=IF(Weekday([Modified])>3, [Modified]+5, IF(Weekday([Modified])>1,[Modified]+3, [Modified]+4))

2. Create a workflow that starts on item created and changed, that pauses until the "escalate date", once that date is reached, workflow checks if item was marked as completed or not.


Explanation of Weekday.

Using Weekday, we can determine which day of the week the share point list item was created and add 3 working days to a calculated column.


WeekdayReturnsDays to addEscalate Date
Sunday1+4Thursday
Monday2+3Thursday
Tuesday3+3Friday
Wednesday4+5Monday
Thursday5+5Tuesday
Friday6+5Wednesday
Saturday7+5Thursday