Saturday, November 23, 2013

Special Characters handling for filename in SP List

I was working with one of our client where we have developed some custom forms [Visual Web Part] which were saving the data in the SP List.
 
Problem: After go-live on the support business has reported that for some of the items they were seeing the duplicate entries for the items. After long analysis i have figured out that it is happening because business were trying to attached the files with special characters. when they tried SP was giving the error message but was not sufficient for some of the users and they were creating those items again instead of editing the already created item to only attach the file without special characters.
 
After a long discussion we agreed to prevent the user on the same form itself instead of saving it and ask user to edit it later.
 
NOTE: This is the case in OOTB SP List as well.
 
Solution:
Insert below script on your form


    function PreSaveAction() {
        var fileNames = document.getElementById('<%=hfExtensions.ClientID %>').value;
        var isInvalidFile = "";
        var attachment;
        var invalid = "no";
        var filename = "";
        var fileNameSpecialCharacters = new RegExp("[~#%&*{}<>;?/+|\"]");
        var attachmentID = document.getElementById("idAttachmentsTable");
        for (var k = 0; k < attachmentID.getElementsByTagName("span").length; k++) {

            try {
                attachment = attachmentID.getElementsByTagName("span")[k].firstChild;
                filename = attachment.data;
                for (var h = 0; h < fileNames.split(',').length; h++) {
                    if (filename.split('.')[filename.split('.').length - 1] == fileNames.split(',')[h]) {
                        isInvalidFile = "invalid";
                        break;
                    }
                }
                if (isInvalidFile == "invalid") {
                    break;
                }
            }
            catch (e) {
            }
            if (fileNameSpecialCharacters.test(filename.split('\\')[filename.split('\\').length - 1])) {
                invalid = "yes";
                break;
            }
            else {
                invalid = "no";
            }
        }
        if (isInvalidFile == "invalid") {
            alert('The file you are attempting to save or retrieve has been blocked from this Web site by the server administrators');
            return false;
        }
        else {
            if (invalid == "no") {
                return true;
            }
            else {
                alert('A file name cannot contain any of the following characters: \\ / : * ? \" < > | # { } % ~ &.Please remove the character and try again.');
                return false;
            }
        }
    }

Tuesday, April 16, 2013

Content Type Hub for your Enterprise

Content Type Hub is the new verbage or term you might here a lot while talking about SharePoint 2010 as a enterprise level solution for document or record managment.

In my last assignment we have used Content Type Hub as it was an enterprise level Record Management System implementation. We have heard or known SharePoint as a Content Management System (CMS) since MOSS, but to me it actually comes with SharePoint 2010.

So when we started our implementation in early 2011, it was very tough for me as well to understand what it Content Type Hub and how it works. But thanks to SharePoint 4 Developer I found the answer in very easy language here.

Now, each new feature comes with their pros and cons. So, here are the cons or limitations for using the Content Type Hub.

Search with SharePoint 2010

Below are some of the best blogs for configuring and customizing Search and understand how search works with SharePoint 2010.

How to build a good enterprise level Search Center?

Usage of Content Source

How to restrict your user search experiance?

How to customize your user search experiance?

Managed Metadata Services (MMS) Limitations in SharePoint 2010

I am blogging back after a long long time. Since last 2 years i was very busy in one of the largest migration assignment from DCTM to SharePoint 2010.

We have build one of the largest Record Managment System in SharePoint 2010 history.

So I just wanted to share some of my learnings and findings from some other blogs here.

Managed MetaData is one of the biggest term from SharePoint 2010 for their Record/Document Management system, though there are some limitations associated with the same while using it effectively.

I have found those limitations here.

Do visit this, to know the biggest issue with MMS while deploying the site backup from one environment to another. Or you can write me to know more on my experience.

Saturday, May 21, 2011

WebApplication Permission Policy in SharePoint 2010

After long time I found some time today to share my new experience in my new organisation. Since last 10 weeks I was working on my 1st ever SharePoint implementations assessment assignment. And ad on to that it was for SharePoint 2010.

My Assignment included to set up or to be precise suggest the Architecture for implementation of SharePoint 2010.

One of the requirement from the client is real time. They were planning to make their intranet portal available on extranet users as well. But they want the restriction on some of the confidential documents when same user accessing the portal from extranet.

Requirement: User A is a exist as a Store Manager in AD. He should be able to access the document on portal only when he is accessing it from store or say from Intranet. At the same time when User A is trying to access the same document on portal from Home through extranet the document should not be accessible to him. 

Myth:It can be achieved by using (1) Audiance Target (2) Creating different group for Intranet and Extranet.

Solution: I would say option (2) is half true. But My Document library is having a permission only for Intranet Group. Now when user A who is a part of both Intranet & Extranet Group how SharePoint will know when User A is accessing the portal from Extranet or Intranet?

Answer to this is Web Application Permission Policy in SharePoint 2010.

Step1: Create portal http://myportal for "Intranet Zone"
Step2: Go to Central Admin and Extend "http://myportal" for "Extranet Zone"
Step3: Select the created "http://myportal" and select Permission Policy from the "Ribbon" on the top.
Step4: Create new policy for "Deny" and add Intranet AD group to that, which will prevent the site to be accessed for the defined group in the Deny Policy.

Now when User A is accessing the portal from extranet and entered the site, SharePoint knows that User A is accessing the portal as a part of Extranet AD Group and not allowed him to access the Document Library which is only having an access to Intranet Group users.

Feel free to write to me for any help on this...and click here and here to know more on how to set up site permission policy.

Thursday, October 21, 2010

My Column in Search Result

We have a requirement in our project where we have to fetch the search result from a given list. Additionaly we have to display some columns from the list in serch result display.

We found a good article from Andy Burn's blog for how to do this.

Wednesday, October 20, 2010

Multiple Document Upload with jQuery

Here is the article with jQuery code from Marc for uploading multiple documents in SharePoint library and at the same time you can name, add description and check-in all together. Click here to see the article.

Thanks Marc :)

Graph in Sharepoint

It is amazing, you can now have your own Graphs in SharePoint and that is without much programming efforts. We can now use SPGraphviz.

It is one of the amazing tool which is freely available for create your own graphs.

Wednesday, September 1, 2010

Windows Live ID Authentication for SharePoint

This is a SharePoint feature that allows you to enable your site with Windows Live ID authentication and take advantage of the huge number of already registered Windows Live ID users.

A great feature available on CodePlex