Category Archives: SharePoint

SharePoint related posts

SP2013 JSLink issue

I began working with SP2013 about a month ago, and one of the new features included in this iteration of SharePoint is JSLink. I began researching and found some very helpful blogs and articles explaining how it works and providing examples for its use. I immediately dove in to try it in my own environment.

The first example i tried was from idubbs.com. This is a very basic example which replaces every word in a specific column with the word “Animal”. So i create a custom list, add a new column (taking advantage of the new quick edit feature), and give each item some unique values. Finally I drop the list view web part on a new page i made to test on. After setting up the JSLink to point to my JS file, i clicked save and waited for the magic to happen… Only when it loaded, nothing happened. All of the values in that column were unchanged!

So what happened? I scoured the internet to find anything that might give me a clue as to what happened. I found people having issues with the minimal download strategy, mismatches on the field name they were targeting and the internally stored field name, and certain column types that do not allow custom JSLink rendering.

That last one though… that kind of stuck out to me. The column i had created wasn’t made in the list settings but in the quick edit grid view. To be honest i had no idea how it was being created in the background. I created two more columns, one using an existing site column “Categories” and another created column called “Category”.

Final result is both traditionally created column worked perfectly, while the quick edit column is not recognized. What a headache.

(Views: 245)

Password changes on SharePoint service accounts

If a SharePoint service account’s password changed in AD it may not change in SharePoint. This can cause the account to lock out from AD and, if it is a user account as well, can lock a user out of the network every time that service is called. While it is not a good idea for user accounts to be service accounts or Managed Accounts, it is not uncommon for a development environment to be set up in this way. If this happens execute the following in an administrator Management Shell:

STSADM.EXE -o updatefarmcredentials -userlogin domain\username -password password

This will update the credentials stored in SharePoint.

(Views: 315)

Fix for Chrome browser errors in SharePoint

I found this amazing piece of advice a few days ago to completely fix all issues Chrome has running SharePoint. Here is the link to Royal Tutorials, all credit goes to them for this fix.

The common issues I have seen using Chrome with SharePoint have been with the scrolling and the ribbon row. This is caused in part to how SharePoint renders scrolling/ribbon row and in part how Chrome loads scripts.

SharePoint has invested heavily in their Ribbon UI across most of their products, and SharePoint is no different. They want this easily accessible no matter where on the page you are. To handle that they are overriding the browser native scroll function and using JavaScript to position the page and page elements. Additionally they have JavaScript load events to enable buttons and functions on the ribbon row.

In SharePoint most controls loaded on the ribbon are disabled, and once it passes SharePoint security then the scripts are loaded for that control. If the browser attempts to load the scripts before the control is enabled the control will never be loaded. Internet Explorer loads all scripts in order before executing them, so IE works very will with SharePoint. Chrome on the other hand loads script files as it receives them which results in controls never becoming active.

The solution Royal Tutorials suggests is to add a little logic to the master page.

<script type=”text/javascript”>
window[addEventListener ? ‘addEventListener’ : ‘attachEvent’](addEventListener ? ‘load’ : ‘onload’, function(){
if(_spBodyOnLoadWrapper){
_spBodyOnLoadWrapper();
}
});
</script>

The window adds an event listener for an “attachEvent”. It checks if the _spBodyOnLoadWrapper has been loaded yet or not, and if it hasn’t then it calls the load function before the “attachEvent” executes.

That’s it! Six lines of JavaScript to your master page and you have cross browser functionality in SharePoint 2010.

(Views: 374)

Could not find specified assembly

Last month I started working for a company to finish a project for them. The visual studio solution file had a single project that took around 5 minutes to deploy just from how bulky it had gotten; additionally there is a lot more work to be done. To save myself development time and just organize the project more efficiently I created a new solution fragmented to several projects.

After setting up the event receivers and features to affect only their pieces, it was time to deploy. The main home page is deployed to SERVER/_layouts/name/filename.aspx, so I’ll check there first (I know, deploying your home page to _layouts is silly, but I inherited it and after several recommendations to rebuild using SharePoint standards they still want to use this file).

CouldNotFindAssembly

 

Uh oh, seems like I got an error. The good news is the page is found and SharePoint is attempting to parse the file. So at this point I run through some basic steps for what could be the cause.

  • reset iis
  • manually uninstall and remove the farm solutions and redeploy with a clean slate
  • deactivate/activate features
  • check assembly to ensure a program is not holding it, the “Last Modified” should match the time deployed. (See pic below)

Assembly

 

Looks like the correct “last modified”… wait, what’s the Public Key Token I am using in my file? Looks like when i created the new project the project was assigned a new Token. I switched out the old token with the new token in all places in my project and redeployed which did the trick.

(Views: 274)

Using CSS3 for IE6 and higher in SharePoint

One common problem with modern web development is displaying a consistent look of your site cross platform. CSS3 provides developers some pretty incredible design tools, but without a modern web browser many users will not see them. Suddenly your polished modern looking website looks like a middle school kid hacked html together. Luckily there are some tools out there which provide CSS3 functionality to IE6,7,8 users.

There are a couple tools out there which work well, but the one i chose to use is PIE. The steps to using it are simple:

  1. Download PIE.zip from the getting started page and unpack the contents.
  2. Upload the PIE.htc file somewhere on your server.
  3. Reference it somewhere in your CSS rule with the following line:  behavior: url(path/to/pie_files/PIE.htc);

A complete guide can be found on their site under Documentation -> Getting Started.

Unfortunately SharePoint developers will require a few more steps. By default SharePoint 2010 blocks the .htc file from running on the site. This is a security measure to prevent malicious scripts from being run through the UI. There are two options to allow access to PIE.htc. The first is to disable the security which prevents the file from running or to install the file in _layouts.

If you are only allowed to deploy a sandbox solution you will not be able to deploy PIE.htc to _layouts. So the next option is to reference it from the style library. To get this to work you must either be in permissive file mode or add the MIME type “text/x-component” to the “AllowedInlineDownloadedMimeTypes” list for each web application using PIE. To enable Permissive File Mode go to Central Administration -> Application management –> Manage Webapplications –> General settings. Find the option called “File Browser Handling” and change this to “permissive”. Additionally this will allow PDF files to open in browser on your site.

The second option is to add the MIME type to the Web Application using PowerShell using the following code:

<code>$webapp = Get-SPWebApplication &lt;name or URL of web app&gt;
$webapp.AllowedInlineDownloadedMimeTypes.Add("text/x-component")
$webapp.Update()</code>

This will add functionality to each Web Application which will be running PIE. Making this change will also let you store the PIE.htc inside a document library.

 

References:

http://stackoverflow.com/questions/4255930/sharepoint-2010-css3pie-isnt-working-because-off-behavior-and-specified-url

http://sharepointsoldiers.wordpress.com/2011/11/03/permissive-mode-in-browser-file-handling/

 

(Views: 3111)

Deployment errors – cannot find specified assembly

Today I opened up a branch of code in TFS for the first time in a week to find this error.

Capture

 

This is an error i have seen in the past. From what i can understand the old .dll file is being used by some unknown process. SharePoint sometimes gets “stuck” on different files, and this is one of them. Since some process has the file opened Visual Studio cannot overwrite it, and the error is a result. Here is how I fixed the issue.

  1. Open up a windows explorer and navigate to C:\windows\assemblies.
  2. Find the ProjectName.dll file which is causing the error and delete this from the folder.
  3. Restart the machine.
  4. Rebuild the project and deploy.

This time I got a second error after I fixed the .dll error:

 An error occurred in deployment step ‘Retract Solution’: The language-neutral solution package was not found

This error was new to me, so I did a quick search online and found this article: http://pankajspoint.blogspot.com/2011/01/error-occurred-in-deployment-step.html

The solution is to open up SharePoint Management shell and run the command “(get-spsolution mysolution.wsp).Delete()”. This should take care of the error and you should be able to redeploy it.

 

(Views: 213)