Thursday, July 14, 2011

single quotes for a string in xslt when filtering list data in sharepoint

some times, we may come accross using xslt list view webpart for showing list content and also we may need to filter data based on some query string or some other data.

That data need to be embeded in single quotes ( ' ') to pass it as filter criteria. in such case there concatination of single quote and your required string wont work.

to fulfill this requirement, create a with value = " ' " (i.e., to store single quote)and make use of this variable + ur filter string for filter criteria of that xslt list view webpart.


i am sorry, i couldnt give u sample code. will update this post with sample code soon.

thank u
Raj

Client Object Model to fetch data from sharepoint list

Below ExecuteOrDelay...line should be first line before you execute any client object model script

ExecuteOrDelayUntilScriptLoaded(funDefault, "sp.js");

var context = null; 
var web = null; 

context = new SP.ClientContext.get_current(); 
web = context.get_web(); 
context.load(web);
var list = web.get_lists().getByTitle("Employees"); 
var camlQuery = new SP.CamlQuery(); 
var q = ""++"100"; 
camlQuery.set_viewXml(q);
this.listItems = list.getItems(camlQuery); 

context.load(listItems,'Include(DisplayName,Id,EmpFullName)'); //what ever field you want from Employee list, you can specify here. DisplayName is nothing but 'Title'

context.executeQueryAsync(Function.createDelegate(this, this.onSuccessMethod), Function.createDelegate(this, this.onFailureMethod)); 


function onSuccessMethod(sender, args) 
{
var listEnumerator = this.listItems.getEnumerator(); 
if(this.listItems.get_count()!=0) 
{
while (listEnumerator.moveNext()) 
{
var item = listEnumerator.get_current(); 
var title = item.get_displayName(); 
var body=new Option(title, item.get_item('Body')); 
document.getElementById('divMain').innerHTML=item.get_item('EmpFullName'); //divMain is a div that i added in content editor webpart
}
}



 
function onFailureMethod(sender, args) 
{
alert('request failed....' + args.get_message() + '\n' + args.get_stackTrace()); 
}


Thursday, December 23, 2010

Sharepoint Interviwe Questions Part II

Hi frnz...

i found a site that has sharepoint inerview questions / FAQ's what ever you call them in below URL.
http://www.dotnetspark.com/DotNetQuestion/index.aspx?cate=9

hope it will be useful...

Internet Access for Sharepoint sites

One of the most common scenarios for using sharepoint in organizations is accessing sites from internet for remote users.
To do this there are some simple steps which administrators should care about. Most organizations use firewalls to secure LANs. Steps described here are combination of tasks on firewalls and sharepoint central administration.
1- First of all you have to configure firewall to allow incoming traffic on ports 80 for HTTP and 443 for HTTPS on your server.
2- Open Central Administration and click application management section. Then click Create or Extend Web Application.

3- In new opened page click Extend an Existing web application.

4- Select desired web application that you want to extend for access from Internet.

5- Be sure create a new web site has been selected. Type an appropriate description for new IIS web site. It can be something like Internet Access. Type port 80 and enter your domain name or valid IP address in Host Header. Set file path for IIS web site.


After doing these changes URL field value will automatically change to the value you typed in Host Header field.
For final step select Internet from Zone combo box and then click OK.

After passing these steps you decide to use form authentication or remain on windows integrated authentication.
For users outside organization it could be a good idea to use form authentication with ASPNET Membership provider which gives you the ability to seperates Active Directory users from users coming outside organization. (I’ve placed link to form authentication in previous posts.)

You can also enable anonymous access and give users ability to login. (to know this check this URL: http://blogs.devhorizon.com/reza/?p=498 )

----Plz post your comments, if you find any mistakes in this article. or you can suggest some other best options too.

Hiding the SharePoint Title Field

Problem: When you create lists by default there is a TITLE column created. When a user fills out the list details you don't want this field to be displayed. How can I hide this field?

Solution:

step 1. After creating a SharePoint list, click on List Settings.

step 2: Click on Advanced Settings under General Settings

Step 3: Then, under Content Types - Allow management of content types set it to YES. By default it is NO and click OK.

step 4: You will be then re-directed to the List Settings page and if you notice there is a new option available as Content Types. Click on "Item" under this.

Step 5: You will then see the below screen. Click on "Title" under Columns. As this is a new list I didn't create any additional columns. If you have created any columns you would see them under the Columns section.

Step 6: You will see the below screen and then choose Hidden (will not appear in forms). That's it!.Simple, yes?

This is it!!!! To check, if you go to the list and click on new item you will see that Title is not there...enjoy!!!

Note: This technique also works for other fields. You may also have to remove the Title field from any Views created.

Creating SharePoint Web Part Pages

Problem:
By default, SharePoint (WSS3 and MOSS 2007) builds a main page for every site. However, I would like to have multiple web pages in a particular site so I can build different environments for various projects and teams within a single site.

Solution: It would be common for different teams to want to see different filtered 'views' of the same lists or libraries. To present a set of filtered content to a distinct set of users, you can build a "Web Part Page" for each project or team. Each page can contain multiple web parts of existing content in a filtered view
In this article I will show how to create a Web Part Pages library, creating a few new Web Part Pages, and then describe how different teams can look at the same target (calendar and document) resources using a pre-filtered view for a particular team. These pre-filtered views will show only the data needed for each team.


Step1: In a WSS3 or MOSS 2007 site, click on "View All Site Content" in the Quick Launch area
(left).
Step2: Then click the "Create" link.
Step3: Choose "Document Library" as the object type (you can choose as per your wish also)
Give the document library a name. In a production environment, in the Navigation choice, you may choose to leave this library out of the Quick Launch area and choose a different method of navigating. This option can be changed later. It makes no difference for the purpose of this exercise.
Choose "Web Part Page" as the "Document Template".
--end of creating document library to store webpart pages---
Adding Web Part Pages:
1. In the new library, click the "New" dropdown and choose "New Document".

2. Give the Web Part Page a Title and then choose a desired layout. The little graphic on the bottom left shows an approximation of what the page layout will look like. With just the web browser*, you cannot change the layout style, so be deliberate with the choice. Don't worry too much, you can always just delete the page and create a new one.
(* With SharePoint Designer, you can add or remove Web Part Zones. What's a Web Part Zone? It's the little areas on the Web Part Page where you can place web part objects. Each of these say "Add a web part" when you are in page edit mode.)

3.The next page offers a blank "Web Part Page", where you can add web content as desired.
4. After creating a few of these pages, I end up with a document library that looks with items with your page name.

Introduction to Windows Powershell for SharePoint 2010

Problem : Lately, there has been growing demand for information about Windows Powershell and SharePoint. The reason is because it is so powerful and easy to use. The built-in commands can handle administrative tasks that are just not possible through Central Administration. Although, Powershell can be used for different technologies we will concentrate on the usage of Windows Powershell for SharePoint starting with a brief introduction.
Solution : If you don’t have Powershell installed you can get it from
here. If you are using SharePoint 2010 then it’s a pre-requisite to have this; therefore it will be installed during the installation.
Open Powershell by finding it in your Programs or run "powershell.exe". Once loaded you will see a basic Powershell command prompt


To get a list of all the built-in commands (cmdlets) in Powerhsell just type get-command format-list. (Note: Powerhsell is not case sensitive).
--------
get-command format-list

--------
Notice there is a symbol in the command with a vertical bar "", this is called a Pipe. The Pipe is used to separate different parts of the command. The different parts can be used to include options, formatting or a way to pass variables.
Some examples :
Let’s say you want to list all of the services on your system. This is the simple Powershell command to do this.

--------
get-service
--------
Let’s say you want to list all of the services on your system, sort the list by the status of the service and return the results in a table format . This is the Powershell command to do this.

--------
get-service sort-object status format-table

--------
Passing variables
Let’s say you want to store the data of all the services in variable called "svs".
Variables always start with a $ letting the shell know that it is a variable. So, the commands will be as follows:
--------

$svs=get-process$svs
--------
The first line will store all the running processes in variable "svs". The second line will return all of the data that was stored in the variable "svs".