There are a couple of methods for this available in the object model without the need to handle the slashes etc yourself, one method using MakeFullUrl:
var fullUrl = item.ParentList.ParentWeb.Site.MakeFullUrl(item.ParentList.DefaultDisplayFormUrl);
A string that specifies the
Add the Microsoft.Office.Server.Search.Query reference to your solution
Then in your code behind, use this reference as the following
The CSOM (and the JSOM by extension) is a Microsoft generated collection of libraries that acts as a proxy to the server-side object model. You can see three different forms:
In SharePoint 2013 it was greatly improved as it got additions for working with search, BCS, taxonomies, workflows and user profiles, and many more. You can ...
you can use SpsiteDataQuery. Also you can try to use OOTB content query web part.
From Link above
query.Lists = "<Lists><List ID='7A9FDBE6-0841-430a-8D9A-53355801B5D5' /><List
Maybe your module files are not deployed as GhostableInLibrary (see e.g. here for a definition of GhostableInLibrary vs Ghostable).
Would you share the code your XML element (module) that deploys the files into the library?
GhostableInLibrary must be explicitely set on the Type attribute of each File node.
The problem was not about the ...
Microsoft.SharePoint.Publishing is the assembly that we need to use to get pages created and published. A sample is provided below:
using (SPSite site = new SPSite("http://moss"))
using (SPWeb web = site.OpenWeb())
PublishingSite pSite = new PublishingSite(site);
SPContentType ctype = pSite.ContentTypes["Welcome Page"];
You have two options for this type of event handling when developing for SharePoint Online: Remote Events Receivers and WebHooks.
Remote Event Receivers are similar to Server-Side Event Receivers but instead of the event triggering a call to code running on the SharePoint Server, it triggers a call to an external web service. In that web service you can use ...
In your code you have set ID 833, so it will only update the item which has ID 833.
Modify your code as below:
using (SPSite spSite = new SPSite(siteName))
using (SPWeb spWeb = spSite.OpenWeb())
spWeb.AllowUnsafeUpdates = true;
StringBuilder methodBuilder = new StringBuilder();
string batch = string.Empty;
spfield.SelectionGroup = newgroup.ID;
MSDN: SPFieldUser.SelectionGroup property
Sample: Programmatically Set "Person Or Group" Column To Select User From A Specified Group
The clear answer is
No, You cannot use Server Object Model in SharePoint Online.
So what may be an alternative?
Also, SharePoint Online does not entertain any deployment of managed CSOM, you can code your ...
This is because you are passing the full url instead of relative url
elevatedWeb.Webs.Add(title, title, strDescription, nLCID, WebTemplate, uniquePerms, bConvertIfThere);
We normally use a setting in for example the property bag of the web application or farm for storing the "root" site collection URL or GUID.
Then you can read this in your user control and from that open the correct site
SP.Update() should work after you add the solution to the farm.
var complete = false;
complete = SPFarm.Local.Solutions[“solutionName.wsp”] != null;
Your code is fine.
I would not attempt to circumvent the problem as it may be telling you that there is in fact something wrong with your setup.
There are many reports (I've experienced this myself) where the User Profile Service is throwing exceptions and needs to be brought back to full health.
Go to Central Admin -> Manage Web Applications. Find ...
using (SPSite site = new SPSite("SiteURL"))
using (SPWeb web = site.OpenWeb())
if (web != null)
SPQuery query = new SPQuery();
query.ViewAttributes = "Scope='Recursive'";
query.RowLimit = 2000;
CamlQuery caml = new CamlQuery();
caml = "<OrderBy Override='TRUE'><...
You can try using SPSecurity.RunwithElevatedPrivilege for using impersonation in your case. it will elevate the access to the system account for running some chunk of the codes. below is the sample:
// do your stuffs
using (SPSite site = new SPSite(web.Site.ID))
//Do things by assuming ...
Try like this for getting the groups and users in site collection
/// UsersCollection is object to get all users by selected web object.
Run with Elevated privileges runs the Code in System Account/App pool account. So you will have to make sure that App pool account has "Manage Profile Permission" rights to the User Profile Service. Follow below steps:
Go to Central Admin-->Choose Application Management --> Manage Service Applications-->
Select the User Profile Service Application (do not ...
for your origional question iv answered here about getting the root web of a site:
for the root web of the site collection:
SPWeb spWeb = SPContext.Current.Site.RootWeb;
SPList spList = spWeb.Lists.TryGetList("MyList");
if its the root web of the root site collection than roberts way is the right way to get the spsite root!
SPSite URL value
following on ...
To access the rootweb use
var rootWeb = SPContext.Current.Site.WebApplication.Sites.RootWeb;
If your user will not have access to this collection, you must open it up in elevated privileges:
using (SPSite site = new SPSite(SPContext.Current.Site.WebApplication.Sites.Id))
You should not have to get the current user. Calling GetUserProfile(bool) will get the user profile of the current user, and optionally create the user profile if it does not exist. The user should have permission to update their own profile, so it is very bad practice to use RunWithElevatedPriveledges. You should only need the Service Context for the ...
You have to use SPSocialFollowingManager to follow a user to document/site etc in Server Object model.
Below is a code snippet how to do it.
//Get the UserProfile for user
SPServiceContext serverContext = SPServiceContext.GetContext(properties.Web.Site);
UserProfileManager profileManager = new ...
The problem with your code is that SPContext.Current.Web will obviously return the current web, not the one in the "Root" site collection. Suppose you have two collections
Now, if you browse a website under http_//sharepointFarm:777/sites/myCollection the context will point to that ...
The default format for SharePoint REST endpoint is application/atom+xml. Instead of manipulating results returned in Xml format you could specify JSON format.
Use accept header to specify the format for response data from the server. To get the results in JSON format, include an Accept header set to application/json;odata=verbose.
The code in ...
Can you try this code snippet
public static void getPermissionsOfFolders()
using (SPSite site = new SPSite("http://sp"))
using (SPWeb web = site.RootWeb)
SPList list = web.GetList("/Lists/List2");
foreach (SPListItem item in list.Folders)