Monday 31 October 2011

Customizing SharePoint list form ruined the entire form

Customizing new form or edit form with SharePoint designer, some times ruined entire form if you delete ListFormWebart from the form.
This may also result in affecting other form of the same list.

We encounterd this problem once on our test environment. After searching heavily on internert I found below post which helped me a lot and saved my time.
http://blogs.msdn.com/b/dszabo/archive/2007/02/20/custom-list-newform-aspx-ruined-in-wss-3-0.aspx

The post gives you step by step things which you need to follow. Just to add one point, while following these steps make sure you save your work only after last step. Saving your work in between may ruined other form.

Quick Update
In case if you want to customize your edit form or new form, hide the ListFormWebPart control and insert the Custom List Form control to your page.



JavaScript and SharePoint List Form fields

Sometimes we need to hide some of the fields, set default value for fields, get the current value of fields on List new form, and edit form, display form.

We can achieve this using JavaScript.

To start with, Microsoft Team has given a good solution on this post http://blogs.msdn.com/b/sharepointdesigner/archive/2007/06/13/using-javascript-to-manipulate-a-list-form-field.aspx

But there are some catches, when we use code given in above post for controls like check box, multiple line textbox.
There is a very good post on cleverworkaround which has much improved JavaScript to overcome these controls.
http://www.cleverworkarounds.com/2008/02/07/more-sharepoint-branding-customisation-using-javascript-part-1/

To return values for SharePoint field types from newform and editform, below is good post given by Alexander on his blog SharePoint JavaScript
http://sharepointjavascript.wordpress.com/2008/12/02/return-value-of-all-sharepoint-fieldtypes-with-javascript/

Hope all these information will be helpful for all of you.

Thursday 20 October 2011

How to add if else if statement in calculated columns of SharePoint 2007

This is what I want to achieve

if(status = "Bad")
then rating = 1
else if(status = "Good")
then rating = 2
else if(status == "Excellent")
then rating = 3

to achieve this I created a calculated column "Rating" and added below formula

=IF([status]="Bad",1,IF([status]="Good",2,IF([status]="Excellent",3)))

And it was returning perfect results required to me.

There are also lots of sample formulas available at below link:
http://office.microsoft.com/en-us/sharepoint-server-help/CH010176029.aspx?CTT=97

Wednesday 7 September 2011

Retrieving Rich Text Box value using JavaScript in SharePoint

Few days back I was working on one requirement to customize SharePoint list form(newform.aspx) using SharePoint designer 2007.

And I was unable to retrieve value from Rich Text box field "Analysis" in JavaScript.

I solved my issue using below JavaScript

<script type="text/javascript">

 var varAnalysis = getTagFromIdentifierAndTitle("textarea","TextField","Analysis*");
 var varAnalysisTextBoxID = RTE_GetEditorDocument(varAnalysis.id);
 var varAnalysisText = varAnalysisTextBoxID.body.innerText;

function getTagFromIdentifierAndTitle(tagName, identifier, title)
{
 var len = identifier.length;
 var tags = document.getElementsByTagName(tagName);
 for (var i=0; i < tags.length; i++)
 {
  var tempString = tags[i].id;
  if (tags[i].title == title && (identifier == "" || tempString.indexOf(identifier) == tempString.length - len))
  {
   return tags[i];
  }
 }
 return null;
}
</script>

This code solved my problem.





How to get GUID of a SharePoint List or Document Library.

In Sharepoint , the easiest way to get GUID of List is:
  1. Go to Sharepoint List or Library Setting
  2. Click on Audience targeting settings 
  3. Copy the url from the browser
  4. You will get url something like this http://Sitename/subsites/_layouts/ListEnableTargeting.aspx?List={7a6d10fa-267c-468c-8d1e-1030323a5846}
  5. From the url we only need text which is after ?List=
  6. That text is GUID for the respective list



How to get Public Key Token using Visual Studio

Most of the times we need public key token of DLL to use it in web.config. We can get the public key token using Visual Studio.

To get that, we need to follow below steps:
1) In Visual Studio, Go to Tools and then click on External Tools


2) New window will open, then click on Add and enter the details as below:
  1. Title: Get Public Key Token
  2. Command: It depends on where you installed SDK. In my case it is C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\sn.exe
  3. Arguments: -Tp "$(TargetPath)"
  4. Also check the checkbox "Use Output Window" and uncheck other checkboxes
3) Click on OK button. Now the "Get Public Key Token" will be available in Tools:

 

4) So now we are ready to use this. After giving strong name to your assembly, you can click on "Get Public Key Token". You will get Public Key Token in output window.

Related Posts Plugin for WordPress, Blogger...