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...!!

Thursday, December 1, 2011

SharePoint 2010 New Features


Microsoft is releasing a slew of new technologies in 2010, and one of the most important of them is SharePoint 2010. Previously known by the code name SharePoint 14, SharePoint 2010 marks a significant upgrade to the SharePoint product. Here are ten of the most important things about the SharePoint 2010 release, which is expected to be available in the first half of 2010.

1. Enhanced SharePoint Designer—Microsoft SharePoint Designer 2010 sports a new UI, improved workflow, and improved integration between designers. Although there were doubts about the Office 2007 ribbon-style interface when it was first released, Microsoft has been steadily putting the ribbon UI in many of its products, including SharePoint 2010. The new designer also has a tabbed interface and provides breadcrumb navigation.

2. New browser support—SharePoint 2010 supports an extended set of browsers. It's designed to support XHTML 1.0–compliant browsers and will support Internet Explorer (IE) 8.0 and IE 7.0, Firefox, and Safari. Notably, IE 6.0 isn't supported. So far, there's been no official mention of Google Chrome or Opera.
3. Enhanced collaboration features—SharePoint 2010 supports tagging content as well as providing enhanced blog authoring capabilities. There's a new group authentication feature that's based on distribution list or organization and a new rich text editor for creating wikis. In addition, calendars from Microsoft Exchange Server can be merged with SharePoint calendars.

4. Visio Services—Visio Services in SharePoint 2010 lets users share and collaborate on Visio diagrams. A built-in viewer lets SharePoint users view Visio files in their browser without having Visio installed on their system. Visio Services also retrieves and renders any external data used in the Visio diagrams.

5. Usage reporting and logging—SharePoint 2010 includes a new database designed to support usage reporting and logging. The usage database is extensible, allowing third-party vendors to create custom reports based on the information it contains.

6. FAST Search—The new SharePoint release will incorporate the FAST Search technology that Microsoft acquired from the Norway-based Fast Search & Transfer company. The FAST technology provides a superset of the original SharePoint search capabilities. As its name implies, FAST Search is designed for high-end scalability. It supports a number of enhanced capabilities, including a content-processing pipeline, metadata extraction, visual search, and advanced linguistics.

7. SharePoint Best Practices Analyzer—With the SharePoint 2010 release, SharePoint Best Practices Analyzer will be incorporated as part of the base SharePoint product. This tool provides Microsoft's guidance for SharePoint implementation and troubleshooting. A Problems and Solutions page in the analyzer helps you solve common implementation problems.

8. New software requirements—In addition to new hardware requirements, SharePoint 2010 will require an x64 edition of either Windows Server 2008 or Server 2008 R2. It also requires a 64-bit version of Microsoft SQL Server 2008 or SQL Server 2005.

9. New hardware requirements—Like the majority of new Microsoft servers, SharePoint 2010 will ship only as a 64-bit product. If you're deploying SharePoint on new hardware, this situation shouldn't be a problem, but it's definitely a consideration if you're planning to upgrade an existing SharePoint server.

10. New SharePoint editions—In an effort to better unify the SharePoint lineup, Microsoft will make some big changes to the SharePoint editions with the 2010 release. Windows SharePoint Server (WSS) is gone, and so is Microsoft Office SharePoint Server (MOSS). The free WSS has been replaced by the new SharePoint Foundation 2010. MOSS is replaced by SharePoint Server 2010, which will be available in either the Standard or Enterprise edition as well as in editions for strictly internal sites and for Internet or extranet sites.

  Any Query ???