Showing posts with label SharePoint Tips and Tricks. Show all posts
Showing posts with label SharePoint Tips and Tricks. 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;
            }
        }
    }

Tuesday, April 16, 2013

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.

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.

Sunday, May 16, 2010

Search Crawling Stops or The parameter is incorrect in sharepoint search

This is one of the worst problem I came across. :(

I don't blame Microsoft for this, but I can say a wrong governance model is the reason for this.

Problem: My client complaint that a new item added on the site is not comes under a search result since last few days. I spent lot of a time to find out the real cause. When I have gone through the Search Crawling log an error is found saying "The parameter is incorrect in sharepoint search". When I checked for all the other sites on the farm all are working fine with search and none of the site has given such error at the time of crawling. That has increased my curiosity.

After spending a full day at last I found a reason and its a cause for small party ;), thanks to Mattias Lindberg

Solution: The reason which stops the crawling for the site is the user we have added in the site are more than 5000 in a particular group instead of adding an AD Group.

I am just copying the workaroung given by Mattias below.

Our solution was to require sites with over 1500 members to use an AD group for keeping track of membership, as recommended by the KB for SPS 2003. One disadvantage with this approach is that you must maintain membership by updating the AD group so you can no longer request membership using SharePoint standard dialogs.

Probably an article is wriiten for SPS 2003 but infect it is applied to MOSS 2007 as well.

Set Domains for People Picker in SharePoint

I am currently working with one of the retail client where we have one requirement as below.

Client is having 4 different domains set for their different group of companies.
1) abc, 2) def, 3) uvw and 4) xyz.
Now client doesn't want a users from domain "uvw" to search by anyone (including site admin) in people picker.

Solution:
I have found a very good article by Joel Oleson @ set propery for people picker

you can use a command as "stsadm.exe -o setproperty -url http://server:port -pn "peoplepicker-searchadforests" -pv "forest:foo.corp.com;domain:bar.foo.corp.com", LoginName, Password"

Thursday, May 13, 2010

Charting in SharePoint using Google APIs

Charts in SharePoint using Google APIs, very good article from Alexander Bautz on EndUserSharePoint.

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

Friday, May 7, 2010

Session Timeout in SharePoint

Since long I have a question that how can I implement a session time out in SharePoint sites. But i never explore as there is no such requirement in any of my project till now.

Suddenly the requirement came and we have to suggest a way to do that with the minimal efforts. And after searching on google i found this and this..., though still we haven't implemented it :(

I am giving you the easiest way directly here to implement that, edit your master page and add the below script in javascript block.

function MySiteTimeOut()
{setTimeout("SessionTimeOut()", 300000);}

function SessionTimeOut()
{document.execCommand("ClearAuthenticationCache");}

This is the same function called when you click on Sign-out in SharePoint site.



Saturday, January 9, 2010

Hide WebPart at run time

In one of my project we had a requirement to hide the WebPart based on the logged in user's department-id. We are not able to use Audiance Targeting to achieve this cuase we were getting user's department id using webservice from 3rd party system only.
What I did, I wrote my custom RSS Viwer WebPart with custom field. And Thanks to SharePoint Developer Center, I found a solution to hide the webpart at runtime very easily.
See the Code Snippet below.
protected override void OnPreRender(EventArgs e)
{
if(your condition)
HideWebParts();
}

private void HideWebParts()
{
if (this.WebPartManager.DisplayMode != System.Web.UI.WebControls.WebParts.WebPartManager.EditDisplayMode
&& this.WebPartManager.DisplayMode != System.Web.UI.WebControls.WebParts.WebPartManager.DesignDisplayMode)
{
for (int i = 0; i <>

{
if (WebPartManager.WebParts[i].Title == this.YourCustomWebPartName.Title)
{
WebPartManager.WebParts[i].AllowHide = true;
WebPartManager.WebParts[i].Hidden = true;
} } } }

Friday, December 25, 2009

Monday, September 7, 2009

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 18, 2009

Enumerate Roles and Groups from the site

In one of our application we have to create a Report which Enumerate Role Assignments to retrieve Groups and Users Permissions from the Site.
MOSSHowTo has provided a good solution for that. Click here...