Showing posts with label General. Show all posts
Showing posts with label General. Show all posts

Tuesday, January 1, 2013

Wishing all our readers a very happy new year


As we are now in the year 2013, here wishing all our readers a wonderful and a very happy new year.

Hope all of you have an energetic start of new year. With this note, we would like to mention that after a break we are going to be back soon in fact very soon with lots of new posts of SharePoint.

Without forgetting we also would like to mention that now as we are in 2013 so as our posts will also be of SharePoint 2013 along with continuing with SharePoint 2010.

Keep visiting SharePoint Kings as you always do visit. Thank you for your consistent support.

Tuesday, January 3, 2012

Wishing you all a very happy new year

Hello SharePointKings reader,

Wish you all a very happy new year and prosperous year ahead. Thank you all for being such a wonderful readers. We appreciate your reading and participating in polling. We value your feedback. We will continue to grow and expand our value of sharing the knowledge at its best.

Thank you once again. Keep visiting, sharing and reading SharePointKings.

Sunday, March 22, 2009

Working with large list

Hi all,

Every time we start designing any project on sharepoint, we or I can say all, are having same problem.

Where to store the data in the sharepoint? (Which can be used as data table? in the language of dumb client who want to use sharepoint but don’t know why)

This is the million dollar question for starting any sharepoint project.

And billion dollar answer is none other than SharePoint Custom Lists.

And after deciding to go with the list another question will come about the taxonomy and structure of list.

You may also read so many article that more that 2000 item is hitting performance in the list. And that is true (that is what Microsoft says)

We found one of a very good document from Microsoft regarding the same Issue with title “Working with large lists” here is the link.


It really worth to read this article to decide architecture.

So we found one way to over come this situation.

Scenario: we are analysis SharePoint solution for one of the manufacturing plant.
And data is been stored in SharePoint list. For an example order list is containing a large number of data. So our first concern is how to implement this much data in one list.
One of the best solution we found is we created taxonomy for SharePoint list item. We decided to store order data in list with folder structure.

What we thought is that create a solution which will help to over come this 2k item problem.

First a folder is created for year like “2009” then month like “3” and then we are storing item in that folder. ( according to client they will not get orders more then 2k per month) other wise you keep segregating this with weeks, or days or may be hours according to your need.
So in our case if I’m adding an order today then my folder structure is
Order list/2009/3/my item

Note: we are storing/inserting item in the list programmatically and will post the same thing (how to do it programmatically?) asap

So this will solve our one problem.

And at the same time another problem is how to store other data or other related things like ….. history for an example. And each order is having multiple records in history.

So to over come this problem we user same structure with one more node.
Year/month/ordered/item in the list. and this date is form order created date not history created.

So we can store multiple items almost 2k item related to one particular order.
So our order history list we will have following structure.

Order History List/2009/3/OrderID#27/history item.
Again repeating the same that if history table updated in April even that structure will be the same as we are creating structure according to order.

So this way we can over come form SharePoint view limitation of 2ooo items.

There are a lot of other ways like creating subsite of Order (Main Item) and store related info in that subsite only. And many more are there according to our need and time.

But this is one of the way that we had done and working fine so we thought that better to share the same to every one so that we can get impact if some one had other idea for similar kind of implementation or some draw back or side effect of this implementation so that we can share the same with community. Please fill free to comment and share your idea regarding the same.

Sunday, November 16, 2008

How to iterate SharePoint List Fields using SharePoint web service?

How to iterate SharePoint List Fields using SharePoint web service?
Hi All,
Here is some code snippet that will help you out to get rid of it.
Here is a scenario where I need to iterate fields and populate these fields in dropdown list for selected SharePoint list in dropdown list.
Reference from link http://www.codeguru.com/csharp/csharp/cs_webservices/tutorials/print.php/c8805__2/

private XmlNodeList RunXPathQuery(XmlNode XmlNodeToQuery, string XPathQuery)
{
// load the complete XML node and all its child nodes into an
// XML document
XmlDocument Document = new XmlDocument();

Document.LoadXml(XmlNodeToQuery.OuterXml);


// all the possible namespaces used by SharePoint and a randomly
// choosen prefix
const string SharePointNamespacePrefix = "sp";
const string SharePointNamespaceURI =
"http://schemas.microsoft.com/sharepoint/soap/";
const string ListItemsNamespacePrefix = "z";
const string ListItemsNamespaceURI = "#RowsetSchema";
const string PictureLibrariesNamespacePrefix = "y";
const string PictureLibrariesNamespaceURI =
"http://schemas.microsoft.com/sharepoint/soap/ois/";
const string WebPartsNamespacePrefix = "w";
const string WebPartsNamespaceURI =
"http://schemas.microsoft.com/WebPart/v2";
const string DirectoryNamespacePrefix = "d";
const string DirectoryNamespaceURI =
"http://schemas.microsoft.com/sharepoint/soap/directory/";
const string DataRowSetNameSpacePrefix = "rs";
const string DataRowSetNameSpaceURI = "urn:schemas-microsoft- com:rowset";

// now associate with the xmlns namespaces (part of all XML
// nodes returned from SharePoint), a namespace prefix that
// we then can use in the queries
XmlNamespaceManager NamespaceMngr =
new XmlNamespaceManager(Document.NameTable);
NamespaceMngr.AddNamespace(SharePointNamespacePrefix,
SharePointNamespaceURI);
NamespaceMngr.AddNamespace(ListItemsNamespacePrefix,
ListItemsNamespaceURI);
NamespaceMngr.AddNamespace(PictureLibrariesNamespacePrefix,
PictureLibrariesNamespaceURI);
NamespaceMngr.AddNamespace(WebPartsNamespacePrefix,
WebPartsNamespaceURI);
NamespaceMngr.AddNamespace(DirectoryNamespacePrefix,
DirectoryNamespaceURI);
NamespaceMngr.AddNamespace(DataRowSetNameSpacePrefix, DataRowSetNameSpaceURI);

// run the XPath query and return the result nodes
return Document.SelectNodes(XPathQuery, NamespaceMngr);
}

When you click button you need to populate fields of “MySharePoint List” to dropdown list.
protected void Button1_Click(object sender, EventArgs e)
{
//List Web service instance.
ListService.Lists listService = new ListService.Lists();
System.Net.NetworkCredential cred = new System.Net.NetworkCredential("admin", "admin");
System.Net.CredentialCache cache=new System.Net.CredentialCache();
cache.Add(new Uri("http://localhost:80"),"NTLM",cred);
listService.Credentials=cache;
listService.Url = "http://localhost:80/_vti_bin/lists.asmx";
//Provide SharePoint List name
XmlNode list = listService.GetList("MySharePointList");
//here “//sp:Field” is XPath query we need to pass.
XmlNodeList nodes = RunXPathQuery(list, "//sp:Field");
foreach (XmlNode node in nodes)
{
try
{
bool hidden = false;
bool ReadOnly = false;
string ID = node.Attributes["ID"].Value;
string Name = node.Attributes["Name"].Value;
try{hidden=Convert.ToBoolean(node.Attributes["Hidden"].Value);}catch{}
try { ReadOnly = Convert.ToBoolean(node.Attributes["ReadOnly"].Value); }
catch { }
if (!string.IsNullOrEmpty(ID) && !string.IsNullOrEmpty(Name))
{
if(!hidden || !ReadOnly)
//ddlField is dropdown list which we need to populate.
ddlField.Items.Add(new ListItem(Name, ID));
}
}
catch { }

}
}

Thursday, August 21, 2008

Adding PeopleEditor control in webpart

Hi All,

I wonder sometimes how this people editor works, Because once you just place the people editor control in web part and then it automatically synchronize the Active Directory if web application is configured as Windows Authentication or from Profile database if Web application is configured as Form Based Authentication. you do not need to do any programming for that. it is really a wonderful thing and i really liked this approach.

I faced several challenges while implementing this control in web part. The requirement is like this. we are not supposed to use a default web parts provided in NewForm, EditForm and DispForm, so we removed those web part and placed our own data entry web part having many validations and pop up windows and many code related stuff that would not be possible with the default web parts.

So but obvious that i have to use people editor control in my web part and use it for getting users from AD and then to store it in the List. Now, because we use our own web part, we ourselves have to write a logic to insert the data entered in data entry web part in the list. so we have to code for this control as well.

so i do it like this, first i add the Field in the list and select set the column to People or Group and select the show Field property as Name(with Presence).

First add the Directive at the top of the page

<%@ Register TagPrefix="wssawc" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>


And now you can add the control for peopleeditor anywhere in your webpart. Just place this tag.

<wssawc:PeopleEditor id="peopleContact"
AllowEmpty="true"
ValidatorEnabled="false"
MultiSelect="false"
runat="server"
SelectionSet="User"
width='200px'
Height='25px' />


You can set different properties depending upon your requirements.

Once you have done this, add a reference for this control in your supporting cs file for the web part (ASCX control).

Do not forget to add reference for : Microsoft.SharePoint.WebControls

Add this line

PeopleEditor peopleContact;


Add this line to your CreateChildControl method and before Page.IspostBack condition

peopleContact = (PeopleEditor)this.ctrlCategoryUserControl.FindControl("{controlnameinascx}");


And finally at the time of inserting the data in the list, just perform the following steps.

SPUser objUser = SPContext.Current.Web.Users[peopleContact.CommaSeparatedAccounts];
String strUserToInsert = objUser.ID + ";#" + objUser.Name;


This is the way you will get the user, if peopleeditor's Multi Select True Or False, this will require modifying this code a bit only.

This will do the insertion for this.

At the time of displaying or editing the same value in Editform Webpart and DispForm Webpart (Your custom made, not the default one that comes with moss), you have to perform the following steps.

I assume that you have fetched a ListItem record in table and now that value for peopleeditor from the field of that List is stored in "UserToDisplay" variable. I also assume that you have performed the same steps as mentioned above for NewForm.

then, just set the following.

peopleContact.CommaSeparatedAccounts = UserToDisplay;


This will display the same User in peopleeditor control.

That's it. Your job is done.

Saturday, July 19, 2008

Custom membership provider using SharePoint Custom List

Hi,
SharePoint List Membership Provider.
Custom membership provider using SharePoint Custom List.
Here is Form Based Authentication using SharePoint custom list. Users profile is stored in Custom SharePoint List.
This utility is useful when you want you site users name, password and other user related information stored in Custom SharePoint List and you want Form Base Authentication (FBA) using this custom list. You can mange user from list.

click here to download Assembly and Configuration guide.
  1. solution contains sample userprofile.stp for List
  2. Configuration guide.
  3. source code will be provided on demand.

click here to download utility.

To get utility source code so you can modify according to your requrement write us from Email to SharePoint kings link with Subject "Custom Membership Provider" and your email ID.

Thursday, July 10, 2008

STSADM Windows Application Utility

Hi All,

A Very Good news. We all know the power of STSADM command.

But now this command comes with more power as it becomes very easy to use this superb and powerful, strong command as now it comes with UI windows application.

This utility is developed as a windows application. It has a dropdown that displays all the STSADM options. Once a specific option is selected from the dropdown, it displays textboxes for various parameters.

Download : link

For more information Visit here

Enjoy STSADM

Thursday, June 12, 2008

Calling SharePoint webservices like lists.asmx using javascript

function QueryListEx(listGuid, fields, where, orderBy, rowLimit, extractRows)

  1. {
  2. var a = new ActiveXObject("Microsoft.XMLHTTP");
  3. if(a == null) return null;
  4. a.Open("POST", GetRootUrl() + "_vti_bin/DspSts.asmx", false);
  5. a.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
  6. a.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/sharepoint/dsp/queryRequest");
  7. var d = ''
  8. + "
  9. + "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" "
  10. + "xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope\/\">"
  11. +" "
  12. +" "
  13. +" 1.0"
  14. +" "
  15. +"
  16. +" service=\"DspSts\" document=\"content\" method=\"query\">"
  17. +" "
  18. +" "
  19. + ""
  20. + "
  21. +" xmlns=\"http://schemas.microsoft.com/sharepoint/dsp\">"
  22. +" + listGuid + "']\""
  23. +" resultContent=\"dataOnly\""
  24. +" columnMapping=\"attribute\" resultRoot=\"Rows\" resultRow=\"Row\">"
  25. +" + rowLimit + "\">"
  26. +" " + fields + ""
  27. +" " + where + ""
  28. +" " + orderBy + ""
  29. +" "
  30. +" "
  31. +" "
  32. + ""
  33. + "";
  34. a.Send(d);
  35. if (a.status != 200)
  36. return null;
  37. else
  38. {
  39. if (extractRows)
  40. return a.responseXML.selectNodes('//Row');
  41. else
  42. return a.responseXML;
  43. }
  44. }


function GetRootUrl()
{
var pathparts = document.location.pathname.split('/');
var url = 'https://' + document.location.hostname + '/' + pathparts[1] + '/';

return url;
}

special thanks to (click here for more help)

Thursday, June 5, 2008

Ask Questions

You can ask your questions and queries as a comment to this post. We will try to reply in its comment and so on.


Update: we stop receiving question as we have a lot question pending with answer.
we will reopen ask question soon.

Thanks,
SharepointKings Team



Share your SharePoint Experiences with us...
As good as the SharePointKings is, we want to make it even better. One of our most valuable sources of input for our Blog Posts comes from ever enthusiastic Visitors/Readers. We welcome every Visitor/Reader to contribute their experiences with SharePoint. It may be in the form of a code stub, snippet, any tips and trick or any crazy thing you have tried with SharePoint.
Send your Articles to sharepointkings@gmail.com with your Profile Summary. We will Post them. The idea is to act as a bridge between you Readers!!!

If anyone would like to have their advertisement posted on this blog, please send us the requirement details to sharepointkings@gmail.com