Wednesday, July 8, 2015

SharePoint 2013 .... oh you naughty Managed Metadata Service.

The Managed Metadata Service or Connection is currently not available


So there everyone was using the termstore to happily tag document and list data with great ease using the Managed Metadata Service, when all of a sudden....





WTF!  Oh, breathe, this is SharePoint, these kind of issues are part of the package...let look at the ULS (log).

07-08-2015 14:50:54.86 w3wp.exe (0x2160) 0x2FA4 SharePoint Server Taxonomy f8bn Monitorable Failed to get term store for proxy 'Managed Metadata Service'. Exception: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.     at Microsoft.SharePoint.Taxonomy.Internal.XmlDataReader.GetDateTime(String name)     at Microsoft.SharePoint.Taxonomy.Internal.SharedTermStore.Initialize(IDataReader dataReader, Guid termStoreIdValue, Boolean fromPersistedData)     at Microsoft.SharePoint.Taxonomy.Internal.SharedTermStore..ctor(IDataReader dataReader, Guid termStoreId, Boolean fromPersistedData)     at Microsoft.SharePoint.Taxonomy.Internal.DataAccessManager.GetTermStoreData(MetadataWebServiceApplicationProxy sharedServiceProxy, Boolean& partitionCreated) 4efe179d-3828-e053-26eb-92b558cf8026

Okay, a "keyNotFoundException", seems serious?  Without boring myself, this is how you fix it, with hardly any stress to you :-)  Open SharePoint CentralAdmin, so to Service Applications, select your Managed Metadata Service (if you called it that) and click properties in ribbon, like so...


You will get a popup like this.




Then make sure you backup (just in case) the metadata database, before doing the next steps.

In the DATABASENAME, prefix it with something like "TEMP", then click OK, this might create a DB with this name (you can delete it later).



Check the Managed Metadata Service, it should be working.  But with a new DB...Noooo!  Dont stress.  Repeat the above step, but this time, remove the prefix we added "TEMP" and click OK.

Voila, if all is well, your Metadata will be back up and running, with all its termsets.


In summary:


  1. Rename database for existing Managed Metadata Service.
  2. Click OK
  3. Check Metadata Service working (with new database)
  4. Rename database back to original
  5. Click OK
  6. All should be working.

Why this is caused, I dont know, will it happen again, likely.  If I figure out what the cause is, I will update this post, else, life goes on.









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

Friday, July 27, 2012

SP2010 - Dynamic List filtering - without code, using just the URL

You have a list and you want to filter the list using a URL.

Normally you would do it like this:

http://myurl/sitename/listname/Forms/AllItems.aspx?FilterField1=Country&FilterValue1=America

This is great and you can extend it to include other columns by using FilterField2,FilterValue2,FilterField3,FilterValue3    and so on.

But what if you want to filter the same column with more than one value, using FilterField options will only allow one filter per column.  So in comes "FilterName and FilterMultiValue"

To use, its simple

http://myurl/sitename/listname/Forms/AllItems.aspx?FilterName=Country&FilterMultiValue=America;South Africa

BAM! you now have a filter on the same field, its an OR filter, but its still great :)

Friday, April 20, 2012

Sharepoint 2010 Event Receiver - Deploy and Remove manually

So you want to deploy an event receiver created in Visual Studio 2010 and cant!!!

Well its easy when you right-click the event receiver in VS2010 and click DEPLOY, oh how easy that makes things, butt what if you need to deploy that event receiver on another server.  Good luck with that.

Anyway, along the way, I eventually managed to do it, not without some pitfalls.  Here I describe a method that worked for me.

1. Create event receiver in VS2010

2. Right-click event receiver and click PACKAGE, the WSP file will be created in either your debug/release folder in your bin directory.

3. Copy WSP file to new server.

4. Open SharePoint Powershell

5. Run the following commands

6. Add-SPSolution -LiteralPath "path to wsp file\EventReceiverProject.wsp", you can check if it was installed using: Get-SPSolution "EventReceiverProject.wsp"

7. Install-SPSolution -Identity "EventReceiverProject.wsp"  -GACDeployment -CASPolicies

8. You will likely get an message saying admin service needs to run to Install, then just run this command: "stsadm.exe -o execadmsvcjobs"

9. Now to activate the feature, use the following command: stsadm -o activatefeature -n "EventReceiverProject2_Feature1" -url http://win-dtze75zqh6a

I discovered this at the following link http://social.technet.microsoft.com/Forums/en-AU/sharepoint2010programming/thread/5b8d6a87-1722-4dd3-af8e-767859291db9


You are done.  You can use SharePoint manager to check if you event receiver was correctly attached to your list.


To undeploy, its basically the above steps in reverse :-)


stsadm -o deactivatefeature -n "EventReceiverProject_Feature1" -url http://win-dtze75zqh6a/

Uninstall-SPSolution -Identity "EventReceiverProject.wsp"

Remove-SPSolution -Identity "EventReceiverProject.wsp"







Thursday, March 8, 2012

Sharepoint foundation 2010 - Item level permissions - filer lists in outlook

For this to work, you create the tasks list


Then open SharePoint Designer, open the list, create new workflow.


Create an impersonation step (Note: this step will run using the credentials you opened the SharePoint site with)


The following workflow is an example from some work I did, where we assign full control to only the assigned to person (or group).  I had to also add an additional step to also assign full control to another group (ADMIN), as the workflow would crash if I allowed multiple selection of groups/users for my assigned to column.




Let’s go through each step.

Set a variable equal to the Assigned to field for the current task list item


REPLACE the current task list item rights to Full Control for current Assigned To user/group.  Notice we used replace, this is important.



Then add same rights(as in B) for the ADMIN group, this is to ensure that we also have a group that we can put users into that can see everyone’s tasks.

Save the workflow, publish. Make sure you’ve set the start workflow on item create and change.  So when task is created, rights are assigned, also when task is changed, as assigned to may be changed, so we need to update the task.



Wednesday, December 22, 2010

Sharepoint Foundation 2010 - Create linked lists with header detail display

This will show how to create a header-detail relationship in SharePoint Foundation 2010.  In this tutorial, we will be creating a Orders/ OrderDetails relationship.

Let’s get started:
  1.       We need to create 2 lists and link them together.
a.       Create Orders list
b.      Site Actions > View All Site Content
c.       Click “Create”
d.      Select “Custom List”
e.      Give the list a name, let us call it “Orders”
f.        Click “Create”
g.       After page reloads, click “List Settings” top right on ribbon bar
h.      Scroll down to columns, click “Title” column, so that we can edit it.
i.         (make sure “Enforce unique values is set to YES)
j.         Rename column to “OrderNumber”
k.       Click “OK”
l.         Now click “Create column”
m.    Column Name: “OrderDate”, type = “Date And Time”
n.      Click “OK”

a.       Create OrderDetails  list
b.      Site Actions > View All Site Content
c.       Click “Create”
d.      Select “Custom List”
e.      Give the list a name, let us call it “OrderDetails  ”
f.        Click “Create”
g.       After page reloads, click “List Settings” top right on ribbon bar
h.      Scroll down to columns, click “Title” column, so that we can edit it.
i.         (make sure “Enforce unique values is set to NO)
j.         Rename column to “Qty”
k.       Click “OK”
l.         Now click “Create column”
m.    Column Name: “Product”, type = “Single Line of Test” (Could also be a lookup)
n.      Click “OK”
o.      Again,  click “Create column”
p.      Column Name: “OrderNumber”, type = “Lookup (information already on this site)”
q.      Get information from, select “Orders”
r.        In this column, select “OrderNumber”
s.       (There is the relationship behaviour which can help to maintain data integrity, but it outside of the scope of this quick tutorial)
t.        Click “OK”

2.       Create an  order  and add some orderdetails.  Make sure you select the ordernumber you created in orders when adding orderdetails.

3.       Select Orders from the lists.

4.       Select Site Actions > Edit Page

5.       Under Web Part Tools, select Options

6.       Select Insert related List, click “Orderdetails”



7. Now you have setup a header detail relartionship.



ORD002 selected, showing 0 line items in order detail

ORD001 selected, showing 2 line items in order detail