Hot answers tagged

15

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); Parameters strUrl Type: System.String A string that specifies the server-relative URL. ...


6

It is not possible using Caml query builder tool U2U. you have to build your CAML Query as per below link : Using CAML Query to Retreive from Multiple Lists


5

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: .Net Silverlight Javascript 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 ...


5

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 ID='3D18F506-FCA1-451e-B645-2D720DC84FD8' /></Lists>";


5

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. EDIT: The problem was not about the ...


5

Add the Microsoft.Office.Server.Search.Query reference to your solution Then in your code behind, use this reference as the following using Microsoft.SharePoint; using Microsoft.Office.Server.Search.Query;


4

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"]; ...


4

Try below code. using (SPSite site = new SPSite("Your Site URL")) { using (SPWeb web = site.OpenWeb()) { if (web != null) { SPList list = web.Lists["Your List Name"]; SPListItemCollection items = ...


4

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 ...


4

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; ...


4

Try: spfield.SelectionGroup = newgroup.ID; spfield.Update(); spList.Update(); MSDN: SPFieldUser.SelectionGroup property Sample: Programmatically Set "Person Or Group" Column To Select User From A Specified Group


4

The clear answer is No, You cannot use Server Object Model in SharePoint Online. So what may be an alternative? If you have some sort of SSOM codes then you can convert that codes to CSOM(Managed CSOM, JavaScript or REST API) whatever is more convenient to you. Also, SharePoint Online does not entertain any deployment of managed CSOM, you can code your ...


3

This is because you are passing the full url instead of relative url Replace http://dev-env/sites/site/subsite/ With subsite i.e elevatedWeb.Webs.Add(title, title, strDescription, nLCID, WebTemplate, uniquePerms, bConvertIfThere);


3

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


3

SP.Update() should work after you add the solution to the farm. var complete = false; while (!complete) { complete = SPFarm.Local.Solutions[“solutionName.wsp”] != null; if (!complete){ SPFarm.Local.Update(); Thread.Sleep(10000); } }


3

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. e.g. Go to Central Admin -> Manage Web Applications. ...


3

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'><...


3

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: SPSecurity.RunWithElevatedPrivileges(delegate() { // do your stuffs using (SPSite site = new SPSite(web.Site.ID)) { //Do things by assuming ...


3

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue; $spSite=Get-SPSite -Identity "http://sp/sites/dev" $spwWeb=$spSite.OpenWeb() $spAuditQuery=New-Object Microsoft.SharePoint.SPAuditQuery($spSite) $Today = [DateTime]::Today $DateLimit = $Today.AddDays(-7) $spAuditQuery.SetRangeStart($DateLimit) $...


3

Try like this for getting the groups and users in site collection using System; using System.Collections; using Microsoft.SharePoint; using Microsoft.SharePoint.Administration; namespace Framework.Business.Components { /// <summary> /// UsersCollection is object to get all users by selected web object. /// </...


2

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 ...


2

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 ...


2

To access the rootweb use var rootWeb = SPContext.Current.Site.WebApplication.Sites[0].RootWeb; If your user will not have access to this collection, you must open it up in elevated privileges: SPSecurity.RunWithElevatedPrivileges(delegate() { using (SPSite site = new SPSite(SPContext.Current.Site.WebApplication.Sites[0].Id)) ...


2

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 ...


2

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 ...


2

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 http//sharepointFarm:777/ http//sharepointFarm:777/sites/myCollection Now, if you browse a website under http_//sharepointFarm:777/sites/myCollection the context will point to that ...


2

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. Examples The code in ...


2

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) { ...


2

This turned out to be really simple. There were two FBA users with the same email so I was logged in as the wrong user and had no idea.


Only top voted, non community-wiki answers of a minimum length are eligible