Monday, September 17, 2012

Move/Migrate SharePoint Library/List items/documents


Move/Migrate SharePoint list items/documents and preserve metadata properties
In moving the mass documents to other folder or libraries there is a pretty common way by using Windows Explorer view. But there's a drawback to that method as the metadata properties like document properties get updated in the process - manily the modified Date/Time as well as the user would take on the role of the person that 'Last modfied '. This also applies to copying list data in the data sheet view from one list/library to another.

I have figured out a new way to doing this where you can save the current list properties after moving the documents as a template with content included and redeploying that to other location.

So if you want to move the contents of a SharePoint Document Library or List and be able to preserve the item’s metadata/property values at the same time you should use this method:

The process to move the content of a SharePoint Document library or List and be able to preserve the item's metadata/property values at the same time you should use this method:

1. Create a Blank Document library where you want to move, don't worry about the custom field it will automatically created once document moved.

2. Go to to "Content and Structure" page. You can access this item within the site with Site Actions  >Site Settings then under Site Administration tab there is a option called Content and Structure.


3. Navigate to you Source Library and select the view that you would like to have moved. Then click on  View > Select the view . Then Click on Action > Move...

   Note: You can create you own custom view. Example You want to move 30 days old file. So  create your view which show files for only 30 Days.


 4. You'll then be prompted witha pop-up that will let you navigate to your destination library or Document library .After you find that, just press the OK button and you’ll be good to go!

Monday, September 3, 2012

Leave Application Workflow Using Sharepoint Designer


Leave Application Workflow using SharePoint Designer


Basic Way to create the leave application application in SharePoint is to use the SharePoint Designer, for that you don't have to go into the custom development.

The Steps are as follows :

  1. Create an SPD workflow on the List that is set to start automatically when a new item is created.

  2. Step 1 - Create an action called Assign To-Do Item that is set to the reporting person field of that current item.  This will pause the workflow until the task is completed.

  3. Step 2 - Create a condition that if the item is rejected, then send an email notification and stop the workflow.  Else, if approved, Assign To-Do Item to Final decision officer.

Below is the Screen shot of the Action Items to be used in SharePoint Designer 2010.



Thanks
Any Question/Suggestion ? 
Please feel free to Contact...!!

Monday, August 13, 2012

Remove “+ Add document" from a SharePoint 2007/2010 Document Library

In this post , i will show you how to hide the "+ Add document " option from the SharePoint Library in SharePoint 2010.

I will explain you with the help of a scenario :

There are some times which we don't need the "Upload Option" in library just due to restrict the user not to upload any file/document.

 In my previous post i have show you the ways to hide the "Upload Button" in ribbon.

Now i will show you ,how to hide the "+Add document" option from library :

Suppose the below is the document library where we want to hide the "+Add document" option :


We can achieve this by the following methods
1.   Editing the WebPart
2.   Using SharePoint Designer(CSS)
3.   Using J Query
4.   By Permission level(Default)

1. Editing the WebPart
Go to Edit WebPart -> Tool bar Type -> Select NoToolBar option which will hide the Add Document option
2. Using SharePoint Designer(CSS)
Go to the designer and edit the page/webpart where you want to hide. Search for class=”ms-addnew” and change the style to Style=”display:none”
3. Using J Query
Add a CEWP and link the following J-Query in it and hide the CEWP webpart

$(document).ready(function()

{

$(‘#WebPartWPQ2 .ms-addnew’).hide();

});

4. By Permission Level (Default)
We can set the permission level for the document library to read only and hence the user with read only option in the SharePoint site will not see this option.

I have done by using the 1st Option. Try it.

Thanks
Any Question/Suggestion ?

Tuesday, August 7, 2012

Disable the Upload Button of a Document library in SharePoint 2010

Disable the "Upload" button of a Document library in SharePoint 2010

There are two ways to disable the upload button :

1st way :

Open your site using SharePoint Designer.  Once opened, navigate to your Library and edit your default view.  (All Files -> Your Library -> Forms -> Your View.aspx, right click and select Edit File in Advanced Mode)

At the bottom of the screen you will see three options Design, Split, and Code.  Select the Split option.

In your code window, locate the <asp:Content ContentPlaceHolderId=”PlaceHolderMain” runat=”server”>  tag.
Now, scroll down and find the closing </asp:Content> tag.  Insert a line above the closing tag.  Place the following code into that newly created blank line.

<style type="text/css">
 #Ribbon\.Documents\.New\.AddDocument-Large
{
display:none;
#Ribbon\.Library\.Actions\.OpenWithExplorer-Medium
{
display:none;
}
</style>

Click save, then refresh your page.  The Documents tab should now be missing the Upload Document button and the Library tab should be missing the Open with Explorer button.

Using IE, you can find the ID’s of the other buttons in the ribbon.  With your View open in IE, click F12.  Once Developer Tools finishes loading, select Find from the top menu, then click on Select Element by Click.  Back in IE, click on the button you want the ID of.

2nd Way :


I would like to show this by giving an example :-

Suppose i have a document library that uses Infopath form it is termed as Form Library.

When a new form is submitted , a series of workflows are triggered and corresponding task is assigned , etc. I had an issue where workflows were getting started multiple times and the task are also assigned  , and generally causing chaos.

I traced the issue, that users were not using the "New Document" button to create a form,but were also saving old forms and re-uploading them using the "Upload" button which results in duplicate files and duplicate workflows etc.

I resolved the issue by simply removing the upload button from the edit.aspx page in each library using the SharePoint Designer.

Steps to do so :

1. Click on the SharePoint Designer to open the edit.aspx page.

2. In Design view right click the List View Web part and select the XSLT data View from the context menu.

3. Switch to split view and locate the "New" button, and you will see the XSLT code.

4. Set the "td " visibility as "hidden" as shown below :








In order, to prevent an unsightly 'blank space' in the menu, I moved the location of the hidden button to the last button on the right of the menu. 

Now users have to use the "New" button to create a new document and cannot use the upload button.
Keep in mind that you'll have to do this for each view that the users have access to, as each view has it's own page that will need editing. 
Thanks

Any Question/Suggestion ??

Tuesday, July 10, 2012

Hiding Empty Columns in Display and Edit form using JavaScript/Jquery

                       Hiding Empty Columns in Display and Edit form  using JavaScript/JQuery

To Hide columns in Display and Edit form both from SharePoint that are empty, for that you don't have get into custom code. A simple client side script is used in form of Jquery.

Code is as follows:

<script type=”text/javascript” src=”/Kishan/Scripts/jquery-v1.7.2.min.js”></script>
< script type=”text/javascript”>
$(“td.ms-formbody”).each(function()
{
// Remove all the white spaces

var val = $(this).text().replace(/\s|\xA0/g,”);


// We will check the string length if it's "0" , hide the field

if(val.length==0){
$(this).parents(‘tr:first’).hide();
}
});

< /script>

To download the Jquery Script file. Click Here.

 

Monday, June 18, 2012

Difference between SharePoint Document library and SharePoint List ?

SharePoint Document Libary :

Document libraries are collections of files that you can share with team members on a Web based on Microsoft Windows SharePoint Services. For example, you can create a library of common documents for a project, and team members can use their Web browsers to find the files, read them, and make comments.

Microsoft SharePoint comes with some pre-defined list and library definitions. These include: Announcement Lists, Blogs, Contacts, Discussion Boards, Document Libraries, External Content (BCS) lists, Pages, Surveys, and Tasks.

Libraries allow you to set up templates for common types of document and also give the option of version control so that you can track any revisions.



SharePoint List :

A List can be thought of as a collection of pieces of information — all of which (typically) have the same properties. For instance, you can have a list of links called "my links", where each item has a name, and a description.

Technically lists also include libraries, but libraries are often seen as separate from lists or at least specialized forms of lists. In lists items are defined by metadata or the columns of a list with documents being attached to that metadata. In a library a document is the item with library metadata supporting the document.

Lists have many features such as workflows, item-level or list-level permission, version history tracking, multiple content-types, external data sources, and many more features. Some of these features depend on the version of SharePoint that is installed.



To summarize for List :

1.  It is best thought of as mini-databases.

2. A list will allow you to store a number of items such as KPIs, tasks, events, staff details etc. in a similar way to how MS Excel or MS Access will.

3.The beauty of SharePoint's lists, is that you can make quick work of building a simple database (with its own, customizable, data entry forms) in a matter of minutes and without any coding. You can also choose which fields to include (title, reference number, status, date etc.) or create your own by creating a new content type and then adding custom columns to it.




Friday, May 25, 2012

WEBPARTS

                                Closed Vs HiddenWebpart's


Closed Webpart :

It can be explained by following points :-

  1.  Closed webpart would not be loaded during the runtime of page.
  2.  Closed webpart reside in it's gallery and can be used anytime according the future requirement.
  3.  To navigate into Closed webpart gallery, just click on the edit page (in SP 2010) then Insert ->    Webpart-> Closed Webpart Gallery.

In SharePoint 2007

Re-Opening a Closed Web Part

To re-open a closed web part:
  • Site Actions > Edit Page:
    • Add a web part
    • Advanced Web part gallery and options
    • Select "Closed Web Parts"
    • Drag-n-drop the web part back onto your page

Hidden webpart :

These are the webpart which we deploy using the Visual Studio. Main difference between Closed and Hidden is that hidden webpart will be loaded in the webapge during the real time, but want appear to the user in the web browser.

These webpart are to be deployed using the Visual Studio.


Thursday, May 24, 2012

Custom List Forms and Redirect to other page after Update

One of my clients required a custom edit form for their editing screen where it would show certain fields and then redirect to a new page after the OK button was clicked. I had done this before at another client except i’d never found a way to actually redirect the page after the save. Here is an article on how to do that to.

1. In Sharepoint Designer take your EditForm.aspx and copy it.
2. Rename it
3. Open this new form and click on the PlaceHolderMain (leave your ListFormWebPart on the page)
4. In the ListFormWebPart scroll down the properties in the xml which describes the webpart and change to false. For some reason the form will not work unless you leave the original on the page.
4. Click on Insert->Sharepoint Controls->Custom List Form5. Choose the appropriate List and select Edit Form
6. Sharepoint generates the form for you.


To customize the save button, find the following control on the page Sharepoint:SaveButton

1. Delete the SaveButton
2. Add

input type="button" value="Save" name="btnSave" onclick="javascript: {ddwrt:GenFireServerEvent('__commit;__redirect={}')}"

instead

3. This button allows the form to be saved and redirects to back to that page. See this article for more info
Hope it helps!

UPDATE:
If you wish to update after redirecting this is how i did it:
add in
ParameterBinding Name=”Source” Location=”QueryString(Source)”
to your paramterbindings list then add
xsl:param name=”Source”>0 /xsl:param>
xsl:variable name=”RedirectLoc”> xsl:value-of select=”$Source”/> /xsl:variable>
to your stylesheet
then the button should be:
input type=”button” value=”Save” name=”btnTopSave” onclick=”javascript: {ddwrt:GenFireServerEvent(concat(‘__commit;__redirect={‘,$RedirectLoc,’}'))}”/>

Tuesday, May 22, 2012

Common Date/Time formulas for Sharepoint – Calculated Fields using Calculated column

Calculate Date -  depends on the week and weekends:

=IF(WEEKDAY(Created)<4,Created+3,IF(WEEKDAY(Created)=4,Created+5,Created+4))

Example :-

If suppose you have submitted the form on 22nd May(Tuesday) then task completion date will be 25th May (Friday).
If  form is submitted on 24th May (Thursday) then the task completion date will be 28th May(Monday).
Same as if form submitted on 25th May (Friday) then the task completion date will be 29th May(Tuesday).

Get Week of the year

=DATE(YEAR([Start Time]),MONTH([Start Time]),DAY([Start Time]))+0.5-WEEKDAY(DATE(YEAR([Start Time]),MONTH([Start Time]),DAY([Start Time])),2)+1

First day of the week for a given date:

=[Start Date]-WEEKDAY([Start Date])+1

Last day of the week for a given date:

=[End Date]+7-WEEKDAY([End Date])

First day of the month for a given date:

=DATEVALUE(“1/”&MONTH([Start Date])&”/”&YEAR([Start Date]))

Last day of the month for a given year (does not handle Feb 29). Result is in date format:

=DATEVALUE (CHOOSE(MONTH([End Date]),31,28,31,30,31,30,31,31,30,31,30,31) &”/” & MONTH([End Date])&”/”&YEAR([End Date]))
Day Name of the week : e.g Monday, Mon
=TEXT(WEEKDAY([Start Date]), “dddd”)
=TEXT(WEEKDAY([Start Date]), “ddd”)

The name of the month for a given date – numbered for sorting – e.g. 01. January:

=CHOOSE(MONTH([Date Created]),”01. January”, “02. February”, “03. March”, “04. April”, “05. May” , “06. June” , “07. July” , “08. August” , “09. September” , “10. October” , “11. November” , “12. December”)

Get Hours difference between two Date-Time :

=IF(NOT(ISBLANK([End Time])),([End Time]-[Start Time])*24,0)

Date Difference in days – Hours – Min format : e.g 4days 5hours 10min :

=YEAR(Today)-YEAR(Created)-IF(OR(MONTH(Today)<MONTH(Created),AND(MONTH(Today)=MONTH(Created),
DAY(Today)<DAY(Created))),1,0)&” years, “&MONTH(Today)-MONTH(Created)+IF(AND(MONTH(Today)
< =MONTH(Created),DAY(Today)<DAY(Created)),11,IF(AND(MONTH(Today)<MONTH(Created),DAY(Today)
> =DAY(Created)),12,IF(AND(MONTH(Today)>MONTH(Created),DAY(Today)<DAY(Created)),-1)))&” months,
“&Today-DATE(YEAR(Today),MONTH(Today)-IF(DAY(Today)<DAY(Created),1,0),DAY(Created))&” days”

You can get Get more formulas from :-

http://office.microsoft.com/en-us/sharepointtechnology/HA011609471033.aspx

OR

http://msdn.microsoft.com/en-us/library/bb862071.aspx

Check out this one..!!
Any Questions/Sugesstions ....!!

Monday, May 21, 2012

Using Calculated Column with maximum number of conditions(IF).

I am just taking an example in which Status column is an choice column with values Choice1 , choice2 and so on. I am assigning the color value based on the selection of status column value.

The Code is :-

=IF([Status]=”",”Black”,IF([Status]=”Choice1″,”Red”,IF([Status]=”Choice2″,”Gold”,IF([Status]=”Choice3″,”Green”,IF([Status]=”Choice4″,”DarkBlue”,IF([Status]=”Choice5″,”DarkCyan”,IF([Status]=”Choice6″,”DarkRed”,IF([Status]=”Choice7″,”Gray”,”"))))))))
For example, if the [Status] column contains Choice5, the output of the formula will be DarkCyan.

You cannot have more than seven nested IF statements in a calculated column.

But there is a worker process, you can do this by using the "&" symbol. Just concatenate these two formulas.

It will only work when the If statements are not nested. Now , i am giving an example of 15 IF functions...!! Check this...!!

The Code is :-

=IF([Status]=”",”Black”,IF([Status]=”Choice1″,”Red”,IF([Status]=”Choice2″,”Gold”,IF([Status]=”Choice3″,”Green”,IF([Status]=”Choice4″,”DarkBlue”,IF([Status]=”Choice5″,”DarkCyan”,IF([Status]=”Choice6″,”DarkRed”,IF([Status]=”Choice7″,”Gray”,”"))))))))&IF([Status]=”Choice8″,”MediumSlateBlue”,IF([Status]=”Choice9″,”SpringGreen”,IF([Status]=”Choice10″,”MidnightBlue”,IF([Status]=”Choice11″,”Sienna”,IF([Status]=”Choice12″,”SlateGray”,IF([Status]=”Choice13″,”OliveDrab”,IF([Status]=”Choice14″,”Gray”,”")))))))

Yeah...!! Finally the code worked...!!
Check out this one..!!

Thursday, May 10, 2012

Show/Hide Lookup fields with jQuery

In my previous post i have introduced you about the hiding the fields using Jquery but that is for the normal site columns. If you are using the Lookup fields then you have to adopt some different approach.

I am just taking any example and explain you by this :

I am hiding the field in the SharePoint Edit Page based on the text value in below column.
Refer to the images that would explain you more clearly

What i am trying to do is when you enter the AU as a Text value in Test Value(Column) then the Test_Status(Column) will hide otherwise it is visible.


In above image Test_Status control is not visible.
In aboe image the control is visible.

Now comes the code :

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
    // add change handler
    $("input[title='Test Value']").change(function() {
        MasterSelectChange();
    });
    // call the change function to set up form for first display:
    MasterSelectChange();
});


function MasterSelectChange()
{
    var thisVal =  $("input[title='Test Value']").val();
    if(thisVal == "AU")
    {
     $("select[title='
Test_Status']").closest("tr").hide();
   
      }
    else
    {
      $("select[title='Test_Status']").show();

    }
}
</script>


Just simply put this code in the body section.


If still there is any issue , please tell me i will try to solve.
Comments Most Welcome...!! :)


Friday, April 20, 2012

Hiding Fields in SharePoint Page's

Hiding fields in SharePoint Page's

(Newform.aspx / EditForm.aspx / Disp.aspx)

Open your website in the SharePoint Designer. Then open your Library. Go into the Form Section then Click on the page (Newform.aspx / EditForm.aspx / Disp.aspx). Click in advanced mode in Ribbon then only you were able to make the changes in the code. Then search for the Below Tag :
<asp:ContentPlaceHolderId="PlaceHolderAdditionalPageHead" runat = "server">
Now Copy the below code and paste it there.
You need to change the Field 1 and Field 2 values only .


<script type="text/ecmascript">

ExecuteOrDelayUntilScriptLoaded(runCode, "sp.js"); function runCode() {
HideField("Expose to Customer / Partner",true); HideField("Field 1",true);
HideField("Field 2",true); } // Function To Hide Fields
function HideField(title,hide){
var header_h3=document.getElementsByTagName("h3") ;
for(var i = 0; i <header_h3.length; i++)
{
var el = header_h3[i];
var foundField ;
if(el.className=="ms-standardheader")
{
for(var j=0; j<el.childNodes.length; j++)
{
var mHead=title+"<SPAN class=ms-formvalidation> *</SPAN>";
if(el.childNodes[j].innerHTML == title || el.childNodes[j].nodeValue == title || el.childNodes[j].innerHTML==mHead)
{
var elRow = el.parentNode.parentNode ;
if(hide==true)
{
elRow.style.display = "none"; //and hide the row
}
else
{
elRow.style.display = "visible"; //and show the row
}
foundField = true ;
break;
}
}
}
if(foundField)
break ;
}
}

</script>

 Wow...!! You're Done...!! Any Query....??

Thursday, April 5, 2012

Getting Dropdown selected Value and Selected Text using JQuery


                 Getting Dropdown selected Value and Selected Text using JQuery

Some we require to get the selected value(id) with their corresponding value. So we can get by this way :-
This is simplest way to get :-

<script type="text/javascript" src="jquery-1.6.2.min.js"></script>
<script language="javascript" type="text/javascript">

$(document).ready(function()
{
$("#btnGetDropDownValue").click(function()
{
alert('DropDown Value '+$("#ddlSample").val());
alert('DropDown Text '+$("#ddlSample").find('option').filter(':selected').text());
});
});
</script>
Call the subsequent parameter where you want to use :-

<table cellpadding="0" cellspacing="0">
<tr><td>Enter Value in TextBox</td><td><select id="ddlSample"><option value="A">A1</option><option value="B">B1</option><option value="C">C1</option></select></td></tr>
<tr><td colspan="2" align="center"><input type="button" id="btnGetDropDownValue" value="Get DropDown Value" /></td></tr>
</table>

Any Query...!!