Showing posts with label SharePoint List and Library. Show all posts
Showing posts with label SharePoint List and Library. Show all posts

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;
            }
        }
    }

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 :)

Sunday, August 29, 2010

Title column Compulsory in Document Library

We had a requirement for one of the project where we were migrating existing portal to SharePoint with almost 11 years of documents.

We had created a document libraries as per requirement, so users where uploading documents in bulk or say multiple documents in once. Now as they were uploading the documents in bulk they wants to make Title field compulsory so it will look better at the view time.

Click here to find the way.

Tuesday, July 13, 2010

Modify the message that appears on an empty document library

We came across a very simple problem, and solution is more simpler. :)

We wanted to change the message appearing when there is no document in the document library.

Solution:The text comes from the core.resx resource file, located in 12\RESOURCES. It's divided up into four resources; just open the resource file in any text editor and search for "noitemsinview_doclibrary", and you'll find the strings.

NOTE: This will change globallly... and you shouldn't rely on changes to the system resource files directly - hotfixes or service packs might overwrite your changes.

Thursday, May 13, 2010

Preview Image on Link Mouse Hover

One of the very common requirement. And I found a very good article on EndUserSharePoint one of my favorite site for learning something new on SharePoint.

Click here to learn how implement a MouseHover on Link for Image Preview.

SharePoint Approval workflow restart on Edit Item

This is a very old and very common requirement. But after working on SharePoint since last 3 years this is the first time I came around with such problem and it is very surprising for me as well that why I never came across such problme in past.

1. I never came across such requirement
2. HotFix is already installed on the servers.

Problem Statement

I have one Document Library called : Company News, I have attached a sequential workflow with Approval and Publisher group with On Add and Edit items. Now whenever a new item is created in document library it starts the workflow and approver approves it.

Once approver approve the item, it goes to publisher being asequential workflow for their approver. But since publisher is also approving the item, it is still showing an item as InProgress.

Solution

Download the HotFix from http://support.microsoft.com/default.aspx?scid=kb;en-us;955586

Tuesday, August 25, 2009

Business Data List Connector - BDC's alternate

This is a good solution provided by Layer2, which will be used as an alternate solution for BDC.
It connects a REAL SharePoint List Without Any WebPart to external business data.
Click here to learn more...

Sunday, August 2, 2009

Show Data from 2 Different Lists

Many of us have a questions on how to show data from a 2 different lists. Laura had provided an answer to that on EndUserSharePoint for the same. :)

Wednesday, July 8, 2009

Item Level Permission for Document Library

There is an item-level permissions feature that can be a solution to this problem BUT it’s only available for lists, not Document Libraries and I found a way to do this provided by Toni on EndUserSharepoint, click here to read more.

Thursday, June 11, 2009

Setting View Column Width with JQuery

One of the very common requirement from the client is to setting up the column width for the Views.
I found very good article from Kjell-Sverre on this. Click here to view full article.

Wednesday, June 10, 2009

Item-Level Auditing with SharePoint Server 2007


Many companies and government agencies have policies and regulations that require them to track carefully where and how users gain access to important records and documents. In particular, they need to maintain audit logs that detail events that track data such as which users viewed and updated records and documents, and when these events occurred.

Now the solution is available with MOSS. Click here

Thursday, June 4, 2009

Combine Multiple Documents

Mark Miller has demonstrate a wonderful way to combine multiple document in a single document.
Take a look and see what I mean.

Multiple Pie Charts in a WSS Dashboard

I have found a good article on how to show multiple Pie Charts in a Dashboard.
Click here to see more...

Thursday, May 28, 2009

Tuesday, May 19, 2009

Best Practice to use DataView WebPart

When you add a data view web part to a page in your site, you’ll notice that when you Save, you get the message, which is called “unghosting” a page, when you customize it away from the site definition. Click here to know the Best Practice to use DVWP.

Friday, May 15, 2009

Data View Web Part, The Basics - Add a Hyperlink (Screencast)

When a Data View Web Part is added to a page in SharePoint Designer, it is sometimes useful to include links to the content of the list. In a regular view of a list on your site in the browser, the list’s Title field is a link to open the item. In a data view web part, this functionality is not automatically included. Following is a step-by-step process for using SharePoint Designer to add a hyperlink to a field in a Data View Web Part.




Monday, May 4, 2009

Sharepoint Download Zipped Documents/List Items

This is one of the gr8 solution we found out for our client's requriment of downloading all the documents/list items in a single click in a zip format. Click here to know more...