Friday 30 May 2014

SharePoint Pure CSS Buttons with hover

As most SP Admins I think would agree, everyone always wants buttons. They want flashy buttons with hover-overs all over their sites.

And this is good! It is an easy way to make a boring SharePoint site look, well, webby.

Creating buttons isn't difficult within itself, except for the arduous task of creating two images per button if a hover is required. The difficult bit lies in resizing, colour or renaming these buttons. Naturally end user's needs change on their sites and so it becomes a bit of a support overhead to constantly be creating buttons.

So i came up with this neat little bit of code which is pure css buttons, colours hovers, text, the lot.

Now it may look a little daunting, but the principle is simple really - a table construct which can be changed to allow for any format of button config, it is here the button names appear as simple href's. This is then followed by css classes, initially applying the main details of the buttons like size, font, alignment and then classes which are hooks for each button, for colour. The following code should be fairly simple to work out.

So, how do we go about applying this? Well, its much better to separate out the code from a content editor webpart so we can control and modify just the txt file rather than editing the site again.

I usually put the following code into a txt file called spbuttons.txt and place it into the site assets library on the local site. Then simply reference this in the content link config of the CEWP, now if you make this relative (../siteassets/) you could export this webpart and place it in the gallery, then all you have to do is copy the txt file into the correct location and straight away you have some buttons on the user's site.


Then your able to modify the text file in its location (I usually open the library with explorer and exit the file straight from SharePoint in Notepad++) and as soon as you save and refresh your result appear immediately.

URL's will need adding into the href on the buttons, give the buttons some names and if you want or need to, change the colours in the css to suit your need. Note this has also got some CSS3 elements here to make the transitions nicer, but it is compatible also is older browsers, just not as sweet. 

Copying the following code and adding as ive described to a CEWP gives the following results:


Hope this saves alot of you alot of time! :)

<table class="spbuttable">
<tr>
<td>

<a href="#" class="spcssbuttonconstruct spcssbutton1" title="Button 1 Title">Button 1</a>

</td>
<td>

<a href="#" class="spcssbuttonconstruct spcssbutton2" title="Button 2 Title">Button 2</a>

</td>
<td>

<a href="#" class="spcssbuttonconstruct spcssbutton3" title="Button 3 Title">Button 3</a>

</td>
<td>

<a href="#" class="spcssbuttonconstruct spcssbutton4" title="Button 4 Title">Button 4</a>

</td>

</tr>
<tr>

<td>

<a href="#" class="spcssbuttonconstruct spcssbutton5" title="Button 5 Title">Button 5</a>

</td>
<td>

<a href="#" class="spcssbuttonconstruct spcssbutton6" title="Button 6 Title">Button 6</a>

</td>
<td>

<a href="#" class="spcssbuttonconstruct spcssbutton7" title="Button 7 Title">Button 7</a>

</td>
<td>

<a href="#" class="spcssbuttonconstruct spcssbutton8" title="Button 8 Title">Button 8</a>

</td>

</tr>
<tr>

<td>

<a href="#" class="spcssbuttonconstruct spcssbutton9" title="Button 9 Title">Button 9</a>

</td>
<td>

<a href="#" class="spcssbuttonconstruct spcssbutton10" title="Button 10 Title">Button 10</a>

</td>
<td>

<a href="#" class="spcssbuttonconstruct spcssbutton11" title="Button 11 Title">Button 11</a>

</td>
<td>

<a href="#" class="spcssbuttonconstruct spcssbutton12" title="Button 12 Title">Button 12</a>

</td>

</tr>
</table>

<style type="text/css">

.spcssbuttonconstruct {
background-color:black;
color:white !important;
display:inline-block;
    font-family: "wf_SegoeUILight","wf_SegoeUI","Segoe UI Light","Segoe WP Light","Segoe UI","Segoe","Segoe WP","Tahoma","Verdana","Arial","sans-serif";
font-style:normal;
text-decoration:none !important;
text-align:center;
vertical-align: middle; 
    display: table-cell; 

    font-weight: 500;
font-size:20px;
line-height: 25px;
height:100px;
width:165px;
}

.spcssbuttonconstruct:hover {

background-color:white;
-webkit-transition: ease-in 0.3s;
    -moz-transition: ease-in 0.3s;
    -o-transition: ease-in 0.3s;
    -ms-transition: ease-in 0.3s;
    transition: ease-in 0.3s;

}




.spcssbutton1 {

background-color:#3cb0e0;
-webkit-transition: ease-in 0.3s;
    -moz-transition: ease-in 0.3s;
    -o-transition: ease-in 0.3s;
    -ms-transition: ease-in 0.3s;
    transition: ease-in 0.3s;

}

.spcssbutton1:hover {

color:#3cb0e0 !important;
-webkit-transition: ease-in 0.3s;
    -moz-transition: ease-in 0.3s;
    -o-transition: ease-in 0.3s;
    -ms-transition: ease-in 0.3s;
    transition: ease-in 0.3s;

}

.spcssbutton2 {

background-color:#008e7f;
-webkit-transition: ease-in 0.3s;
    -moz-transition: ease-in 0.3s;
    -o-transition: ease-in 0.3s;
    -ms-transition: ease-in 0.3s;
    transition: ease-in 0.3s;

}

.spcssbutton2:hover {

color:#008e7f !important;
-webkit-transition: ease-in 0.3s;
    -moz-transition: ease-in 0.3s;
    -o-transition: ease-in 0.3s;
    -ms-transition: ease-in 0.3s;
    transition: ease-in 0.3s;

}

.spcssbutton3 {

background-color:#939392;
-webkit-transition: ease-in 0.3s;
    -moz-transition: ease-in 0.3s;
    -o-transition: ease-in 0.3s;
    -ms-transition: ease-in 0.3s;
    transition: ease-in 0.3s;

}

.spcssbutton3:hover {

color:#939392 !important;
-webkit-transition: ease-in 0.3s;
    -moz-transition: ease-in 0.3s;
    -o-transition: ease-in 0.3s;
    -ms-transition: ease-in 0.3s;
    transition: ease-in 0.3s;

}

.spcssbutton4 {

background-color:#003c27;
-webkit-transition: ease-in 0.3s;
    -moz-transition: ease-in 0.3s;
    -o-transition: ease-in 0.3s;
    -ms-transition: ease-in 0.3s;
    transition: ease-in 0.3s;

}

.spcssbutton4:hover {

color:#003c27 !important;
-webkit-transition: ease-in 0.3s;
    -moz-transition: ease-in 0.3s;
    -o-transition: ease-in 0.3s;
    -ms-transition: ease-in 0.3s;
    transition: ease-in 0.3s;

}

.spcssbutton5 {

background-color:#edd845;
-webkit-transition: ease-in 0.3s;
    -moz-transition: ease-in 0.3s;
    -o-transition: ease-in 0.3s;
    -ms-transition: ease-in 0.3s;
    transition: ease-in 0.3s;

}

.spcssbutton5:hover {

color:#edd845 !important;
-webkit-transition: ease-in 0.3s;
    -moz-transition: ease-in 0.3s;
    -o-transition: ease-in 0.3s;
    -ms-transition: ease-in 0.3s;
    transition: ease-in 0.3s;

}

.spcssbutton6 {

background-color:#e784b7;
-webkit-transition: ease-in 0.3s;
    -moz-transition: ease-in 0.3s;
    -o-transition: ease-in 0.3s;
    -ms-transition: ease-in 0.3s;
    transition: ease-in 0.3s;

}

.spcssbutton6:hover {

color:#e784b7 !important;
-webkit-transition: ease-in 0.3s;
    -moz-transition: ease-in 0.3s;
    -o-transition: ease-in 0.3s;
    -ms-transition: ease-in 0.3s;
    transition: ease-in 0.3s;

}

.spcssbutton7 {


background-color:#6cb33f;
-webkit-transition: ease-in 0.3s;
    -moz-transition: ease-in 0.3s;
    -o-transition: ease-in 0.3s;
    -ms-transition: ease-in 0.3s;
    transition: ease-in 0.3s;

}

.spcssbutton7:hover {


color:#6cb33f !important;
-webkit-transition: ease-in 0.3s;
    -moz-transition: ease-in 0.3s;
    -o-transition: ease-in 0.3s;
    -ms-transition: ease-in 0.3s;
    transition: ease-in 0.3s;



}

.spcssbutton8 {

background-color:#e6c26a;
-webkit-transition: ease-in 0.3s;
    -moz-transition: ease-in 0.3s;
    -o-transition: ease-in 0.3s;
    -ms-transition: ease-in 0.3s;
    transition: ease-in 0.3s;

}

.spcssbutton8:hover {

color:#e6c26a !important;
-webkit-transition: ease-in 0.3s;
    -moz-transition: ease-in 0.3s;
    -o-transition: ease-in 0.3s;
    -ms-transition: ease-in 0.3s;
    transition: ease-in 0.3s;

}

.spcssbutton9 {

background-color:#84be51;
-webkit-transition: ease-in 0.3s;
    -moz-transition: ease-in 0.3s;
    -o-transition: ease-in 0.3s;
    -ms-transition: ease-in 0.3s;
    transition: ease-in 0.3s;

}

.spcssbutton9:hover {

color:#84be51 !important;
-webkit-transition: ease-in 0.3s;
    -moz-transition: ease-in 0.3s;
    -o-transition: ease-in 0.3s;
    -ms-transition: ease-in 0.3s;
    transition: ease-in 0.3s;

}


.spcssbutton10 {

background-color:#3c90b3;
-webkit-transition: ease-in 0.3s;
    -moz-transition: ease-in 0.3s;
    -o-transition: ease-in 0.3s;
    -ms-transition: ease-in 0.3s;
    transition: ease-in 0.3s;

}

.spcssbutton10:hover {

color:#3c90b3 !important;
-webkit-transition: ease-in 0.3s;
    -moz-transition: ease-in 0.3s;
    -o-transition: ease-in 0.3s;
    -ms-transition: ease-in 0.3s;
    transition: ease-in 0.3s;

}

.spcssbutton11 {

background-color:#525451;
-webkit-transition: ease-in 0.3s;
    -moz-transition: ease-in 0.3s;
    -o-transition: ease-in 0.3s;
    -ms-transition: ease-in 0.3s;
    transition: ease-in 0.3s;

}

.spcssbutton11:hover {

color:#525451 !important;
-webkit-transition: ease-in 0.3s;
    -moz-transition: ease-in 0.3s;
    -o-transition: ease-in 0.3s;
    -ms-transition: ease-in 0.3s;
    transition: ease-in 0.3s;

}

.spcssbutton12 {

background-color:#78669b;
-webkit-transition: ease-in 0.3s;
    -moz-transition: ease-in 0.3s;
    -o-transition: ease-in 0.3s;
    -ms-transition: ease-in 0.3s;
    transition: ease-in 0.3s;

}

.spcssbutton12:hover {

color:#78669b !important;
-webkit-transition: ease-in 0.3s;
    -moz-transition: ease-in 0.3s;
    -o-transition: ease-in 0.3s;
    -ms-transition: ease-in 0.3s;
    transition: ease-in 0.3s;

}

.spbuttable {

width: 646px;
border-spacing: 1px;
margin-left:auto; 
    margin-right:auto;
margin-bottom:10px;



}



</style>






Wednesday 28 May 2014

SharePoint 2010 - Navigation back to originating site/list when using a centralised search center

Heading to Site Actions -> Site Settings -> Site Collection Settings -> Search Settings,
there are options for configuring how search works.

A common scenario is when the Search results page is configured to direct the searcher to a centralised search center rather than the default, local '/_layouts/OSSSearchResults.aspx' page:


This is the norm if you have document management configured in your organisation, with centralised content types furnished managed metadata and this all brought together for the end user by using search to return documents across a number of different sites / site collections.

The issue many people run into is this.

The user is searching from their own site, or perhaps from within a document library on their site, and search, due to the configuration you have applied at the site collection level redirects them to another site collection (or perhaps web application) that is hosting the search center. Now this is all well and good, the documents or whatever are all returned in the results and everything appears to be working correctly.

But now, then want to get back to the site they search from or perhaps the list they searched from, but because search is on a different site altogether, all of a sudden there is no breadcrumb to direct them back, hence the user journey is a struggle, adoption is affected, etc.

So, we came up with a solution to this issue. Now this does involve jQuery, but don't let that scare you if you aren't using this on your environment yet, it's pretty easy and to be honest whenever you want to do anything on SharePoint that is a little bit clever and our of the norm you will usually need to use this fantastic library of functions you now have available to you.

(Now, i'm not going to go into how to add jQuery here, this is for a different post, which I will tackle shortly and provide you with a link.)

On your search results page(s), edit the page and add a plain old CEWP (content editor web part), choose 'edit html source' from the ribbon





Add the below code into the html editor and hit the save button. (Do note, the only thing that may vary here is the 'script src' which is the location of your jQuery library, in my instance, I have the library added to the folder in the hive of each of my WFE's in a Javascripts folder).

The way this works is by interrogating the URL, as this holds the source of the query, so when a user hit search from a site, the string 'This%20Site' is in the URL, and if they come from a list, yep you guessed it 'This%20List' is present. So all we're doing when these strings in the URL are found is taking slicing the 14 characters that depict the list or site, exscaping some unwanted characters and adding this as a HREF to a link that says either 'Back to Site' or 'Back to List'. Simples!

You may need to add some additional positioning in the <divclass="divlink" tag to make this appear where you want it.

<script src="/_layouts/javascripts/jquery/jquery-1.9.1.min.js" type="text/javascript"></script>

<script language="javascript" type="text/javascript">
 $(document).ready(function() {
$(".divlink").empty();
 
var url = document.URL;
var findlist = "This%20List";
var findsite = "This%20Site";
  
var listfound = url.search(findlist);
var sitefound = url.search(findsite);
 
 
if (listfound > 1) {
 
newurl = url.slice(listfound + 14); 
newurl = newurl.replace(/%2F/g,"/");
newurl = newurl.replace(/%3A/g,":");
newurl = newurl.replace(/&/g,"");
 
    var link = ("<a href=\"" + newurl + "\">Back to list</a>");
 
 
$(".divlink").append(link);
 
}
 
if (sitefound > 1) {
 
newurl = url.slice(sitefound + 14); 
newurl = newurl.replace(/%2F/g,"/");
newurl = newurl.replace(/%3A/g,":");
newurl = newurl.replace(/&/g,"");
 
 
 
    var link = ("<a href=\"" + newurl + "\">Back to site</a>");
 
  
 
$(".divlink").append(link);
 
}
 
 
});
​​​
</script>
<divclass="divlink" style="font-weight: bold; bottom: 45px"></div>




Project Sever 2010 - OLAP Cube build failing

Within your PWA application -> Server settings -> Database Administration -> OLAP Database Management. Attempting to build the OLAP cubes in Project server 2010
 

An error occurs with the following description:

Failed to build the OLAP cubes. Error: The attempt to build the OLAP database on server pma-poc-sql01 failed, the SQL Server Analysis Services Analysis Management Objects (AMO) client software may not be installed on this server, please install/update the client on this server and retry. The underlying exception was: Could not load file or assembly 'Microsoft.AnalysisServices, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified.

After ages trying to get analysis services to work on a project server 2010 with SQL 2008 R2 implementation...

Basically, on all Web Front Ends and Application servers;
  • install the SQL 2008 native client
  • install the SQL server analysis management objects
You can get these from here:
http://www.microsoft.com/en-us/download/details.aspx?id=8824

Then, head over to central admin -> manage services on server and restart the project application service on all servers in farm (except SQL)

It is also likely you will have to add the farm service account into the SQLServerMSASUser$ local group on the SQL server and add this account also to the security settings in the analysis instance in SQL management studio....

Now, try again to rebuild the cube in PWA. This should then report a build success:

SharePoint 2010 - User Profile Service Application flooding the logs with Event ID 3

I have seen now a few times in a few different organisations, the dastardly issue of the event logs getting flooded with Event ID 3, details of this event below - settle in people, this makes an interesting read....

Log Name:      Application
Source:        Forefront Identity Manager
Date:          28.3.2012 11:13:01
Event ID:      3
Task Category: None
Level:         Error
Keywords:      Classic
User:          N/A
Computer:     server
Description:
Microsoft.ResourceManagement: System.Data.ConstraintException: Schema validation failed.
   at Microsoft.ResourceManagement.Utilities.ExceptionManager.ThrowException(Exception exception)
   at Microsoft.ResourceManagement.ActionProcessor.ActionDispatcher.ProcessInputRequest(RequestType request)
   at Microsoft.ResourceManagement.WebServices.RequestDispatcher.ExecuteAction(RequestType request)
   at Microsoft.ResourceManagement.WebServices.RequestDispatcher.ExecuteAction[ResponseBodyType](RequestType request)
   at Microsoft.ResourceManagement.WebServices.RequestDispatcher.DispatchRequest[ResponseBodyType](RequestType request, Guid requestIdentifier, Object redispatchSingleInstanceKey)
   at Microsoft.ResourceManagement.WebServices.RequestDispatcher.DispatchRequest[ResponseBodyType](RequestType request)
   at Microsoft.ResourceManagement.WebServices.ResourceManagementService.Create(Message request)
Event Xml:
< Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
  <System>
    <Provider Name="Forefront Identity Manager" />
    <EventID Qualifiers="0">3</EventID>
    <Level>2</Level>
    <Task>0</Task>
    <Keywords>0x80000000000000</Keywords>
    <TimeCreated SystemTime="2012-03-28T09:13:01.000000000Z" />
    <EventRecordID>386413</EventRecordID>
    <Channel>Application</Channel>
    <Computer>server</Computer>
    <Security />
  </System>
  <EventData>
    <Data>Microsoft.ResourceManagement: System.Data.ConstraintException: Schema validation failed.
   at Microsoft.ResourceManagement.Utilities.ExceptionManager.ThrowException(Exception exception)
   at Microsoft.ResourceManagement.ActionProcessor.ActionDispatcher.ProcessInputRequest(RequestType request)
   at Microsoft.ResourceManagement.WebServices.RequestDispatcher.ExecuteAction(RequestType request)
   at Microsoft.ResourceManagement.WebServices.RequestDispatcher.ExecuteAction[ResponseBodyType](RequestType request)
   at Microsoft.ResourceManagement.WebServices.RequestDispatcher.DispatchRequest[ResponseBodyType](RequestType request, Guid requestIdentifier, Object redispatchSingleInstanceKey)
   at Microsoft.ResourceManagement.WebServices.RequestDispatcher.DispatchRequest[ResponseBodyType](RequestType request)
   at Microsoft.ResourceManagement.WebServices.ResourceManagementService.Create(Message request)</Data>
  </EventData>
< /Event>


Now, if we look at the ULS log related to this error, we can narrow in a little on the cause:

ULS logs:
UserProfileApplication.SynchronizeMIIS: Error updating users with FIM permissions: Microsoft.ResourceManagement.WebServices.Faults.ServiceFaultException: Unable to process Create message    
 at Microsoft.ResourceManagement.WebServices.Client.ResourceTemplate.CreateResource()  
 at Microsoft.Office.Server.Administration.UserProfileApplication.UpdateFIMUser(SchemaManager schemaManager, String userName, String accountName, String domain, Byte[] userSid)  
 at Microsoft.Office.Server.Administration.UserProfileApplication.SynchronizeMIISAdminsList(Hashtable htPermittedUsers)  
 at Microsoft.Office.Server.Administration.UserProfileApplication.SetupProfileSynchronizationEnginePermissions().


OK, so I told you it was an interesting read, well I lied. Let me make a long story short.
Basically this error seems to not cause an serious problems, the User Profile Sync works without error, no issues with profiles or the like syncing to or from Active Directory, but still its not nice to have this bad boy flooding the event log every day.

The fix? Well, this is actually to do with the administrative account(s) over the UPSA, now this could be the account the you run central admin with or to do with accounts added as delegated administrators over the service app.


 

 
You may have added an Active Directory group as an administrator over the user profile service, for updating profiles or the like. Or you may have added a single user in the box above to grant similar delegation. Notice the two lowermost accounts in the screenshot above? Both of these will cause the error in the event log.
 
The key boils down to there being a blank somewhere in a name field of this account in AD, I think particularly 'Pre Windows 2000 name' field visible in AD Users and Computers.

I have added administrators with account names without spaces for the UPSA without errors, but anytime I have used groups or accounts with spaces the errors occur.

The fix is to simply remove these accounts from the list of administrators. Now if your farm account has a space then.... This may be a slight issue  :)

Chris