Header

Sunday, 14 July 2013

Get Data of current login user in Sharpoint




Get Data of current login user in Sharpoint
some time we need to get data according to current user.
Like items that has been created by current login user.

And there so many approach to do this but,
what I will recommend that never goes wrong.

  osb.Append("     <Where>")
  osb.Append("       <Eq>")
  osb.Append("        <FieldRef Name=""Author"" LookupId=""True"" />")
  osb.Append("        <Value Type=""Lookup""   >" &
                        SPContext.Current.Web.CurrentUser.ID & "</Value>")
  osb.Append("      </Eq>")
  osb.Append("   </Where>")


Just add this query and get what you wanted :D

How to get Site, Web, and List name from a list url

How to get Site, Web, and List name from a list url

Some time we have url of list and need to find its web, list name ...

Basically, we need to split string and get web name and list.
 
We have SharPoint to do this in easy way and also dynamic... :)

 Using siteCollection As New SPSite(listurlfromitems)
            Dim Site As SPSite = siteCollection
            Dim myWeb As SPWeb = siteCollection.OpenWeb()
            Dim _list As SPList = myWeb.GetList(listurlfromitems)
End Using

Here listurlfromitems is a string which holds URL of list
after that we can find site, web, and list in Site, myWeb, _list variable