Tag Info

Hot answers tagged

9

As a part of the new Minimal Download Strategy (MDS) the sp.js library is not loaded until explicitly called in SharePoint 2013. Your case is pretty common, for example for a publishing pages, where sp.js library is loaded in the edit mode but not in the display mode. Solution Prefer SP.SOD.executeFunc over SP.SOD.ExecuteOrDelayUntilScriptLoaded ...


9

This seems to be pretty close in performance: context.Load(lists, all => all .Where(l => l.RootFolder.Name == "MyListUrl") .Include(l => l.Id)); context.ExecuteQuery(); list = lists.Single(); If you need to get this by server-relative url you would need to parse the web url and list url first.


9

Yet another version to load List by server relative Url using CSOM. The solution consists of the following steps: Retrieve list Folder object using Web.GetFolderByServerRelativeUrl method Retrieve List by specifying List ID stored in vti_listname property from Folder.Properties object Code: static class WebExtensions { /// <summary> /// ...


7

Check out this blog post by Andrew Connell where he talks about using Breeze with SharePoint. With Breeze your code will look something more like: var promise = breeze.EntityQuery .from(contactType.defaultResourceName) .using(entityManager) .execute() .where('Id', 'eq', 1) .then(function (data) { return data.entity; }); // update the first ...


7

How to create Variation Labels in SharePoint 2013/Online via CSOM SharePoint 2010/2013 CSOM API does not expose any specific methods for creating Variation Labels, but you could use the following class for that purpose. VariationsClient class is intended for managing Variation Labels in SharePoint 2013. The following operations are currently supported: ...


7

There are two ways to call executeQueryAsync in JSOM: context.executeQueryAsync( Function.createDelegate(this, _onSucceed), Function.createDelegate(this, _onFail) ); and context.executeQueryAsync(_onSucceed, _onFail); The difference between the two is the former allows you to override what the value of the "this" variable will be inside the ...


6

user1901384 is correct, ExecuteOrDelayUntilScriptLoaded won't load it, it will just check to see if it has been loaded. Take a look at this code sample (full page here). You don't need the clientContext part, what you're looking for is SP.SOD.executeFunc() but I left in the clientContext because you might find that helpful as well. Put your console.log('2') ...


6

Use the MasterUrl and CustomMasterUrl properties of Web: using (var ctx = new ClientContext( url )) { var web = ctx.Web; var masterPageUrl = String.Format( "{0}/_catalogs/masterpage/oslo.master", ctx.Web.ServerRelativeUrl ); web.MasterUrl = masterPageUrl; web.CustomMasterUrl = masterPageUrl; web.Update(); ctx.Load( web ); ...


6

Farm Solutions (Full Trust): Develop for SharePoint On-Premises only. Can use managed code and the Server Object Model. This model has been around since SharePoint 2007 and is currently the most robust and well documented. Sandbox Solutions: Develop for SharePoint On-Premises or SharePoint Online. Can currently use managed code and a limited version of the ...


5

First off we needed a page to work on, we could make a request to find default home page, or try document.referrer, but for now we can say it was /SitePages/Home.aspx (we call it variable page). For the sake of the examples we will say that appWebUrl and hostWebUrl are defined (these are available in querystring). Lastly we needed a link to the malicious ...


5

what version of sharepoint you using ? .getByName() This is not in 2010 and was introduced in 2013. The only thing i know of in 2010 that uses getbyname is getting the web role definition. get_web().get_roleDefinitions().getByName("Read Only Access"); im sure there are other things that use it but what your looking for is only applicable in 2013 ...


5

You are missing the <View> tags in your ViewXml (see example here) It should be string qs = String.Format("<View><Query><Where><Eq><FieldRef Name=\"Title\"></FieldRef><Value Type=\"Text\">{0}</Value></Eq></Where></Query></View>", listItemTitle); query.ViewXml = qs; In case of ...


5

You could also use _api/Web/Lists/GetByTitle('List title')/DefaultDisplayFormUrl If you want for all lists do _api/Web/Lists?$select=DefaultDisplayFormUrl Note that the property is not visible when visiting List directly, need full path or $select.


4

When developing JavaScript apps against the SharePoint 2013 REST and CSOM APIs it is recommended to leverage Promises Patterns since it allows separate out the various asynchronous calls while still maintaining the dependency between them. There are several techniques for implementing promises, but one of the easiest is to make use of the jQuery $.Deferred ...


4

You need to use the overload for SPField.Update that takes a boolean parameter. That will push the changes to lists that use the field.. I.e., in Powershell: $myField.Update($true) MSDN documentation here.


4

I know in the JavaScript Client Object Model executeQueryAsync is performed using an XmlHttpRequest, the results of which are cached by default. I would assume the managed client object model requests data using the same method 'under the covers' As for how long the cached request is valid, it appears to be dependent upon the user's browser configuration. ...


4

As an introductory please follow How to: Complete basic operations using SharePoint 2013 client library code article to get acquainted with how to update a SharePoint list item via CSOM. How to update list items via CSOM in PowerShell Assume the following data is contained in CSV file ID,FullName,Company,Title 1,Pilar Ackerman,Contoso Ltd,Manager ...


4

Depending whether taxonomy field is single-valued or or multi-valued use the corresponding method: single-valued taxonomy field: SP.Taxonomy.TaxonomyField.setFieldValueByValue by specifying SP.Taxonomy.TaxonomyFieldValue object multi-valued taxonomy field: SP.Taxonomy.TaxonomyField.setFieldValueByValueCollection Method by specifying ...


4

Try giving "Read" permission to "Web" in AppManifest.xml and it should work.


4

I normally follow as below SP.SOD.executeFunc('sp.js', 'SP.ClientContext', readyFunction); function readyFunction() { getCurrUser(); evalGroups(); getDeptMgrs(); getItemOwner(); } Its more readable!


4

You Can set it by updating the Item with the choice value, as below newListItem["ChoiceFieldName"] = "ChoiceValue"; newListItem.Update(); clientContext.Load(newListItem); clientContext.ExecuteQuery(); But if you are assigning a Value which is not in the Choice Column, You need to create a choice value then assign it to the item.


4

Example 1 Explicitly specify choice value: using (var ctx = new ClientContext(webUri)) { var list = ctx.Web.Lists.GetByTitle("Tasks"); var taskItem = list.GetItemById(itemId); taskItem["Status"] = "In Progress"; taskItem.Update(); ctx.ExecuteQuery(); } Example 2 Choose a value from field choice: using (var ctx = new ...


4

Since SP.ClientRuntimeContext.prototype.load(clientObject) method accepts properties as dynamic parameters, you could consider the following approach: var getList = function (listTitle) { var deferred = $.Deferred(); var ctx = SP.ClientContext.get_current(); var list = ctx.get_web().get_lists().getByTitle(listTitle); //construct ...


4

You can leverage SP 2013 Search API s for this if you have a search configured and continous crawling enabled and there is huge number of sub sites to be iterated otherwise. //Raw code not tested , just to give idea of what it will look like function getSite(){ var clientContext = new SP.ClientContext("<serverRelativeUrl>"); var contextSite = ...


4

CSOM Feature object exposes the following properties: DefinitionId - gets the GUID that identifies the Feature definition DisplayName - feature name Such SSOM Feature properties as SPFeature.Definition or SPFeature.Properties are not available in CSOM/REST. Below examples demonstrate how to manage features using CSOM Example: how to retrieve ...


4

Apart from the explanation given by Amal, the reason you see error is var collListItem; is defined in getAllFilesInFolders function and the onQuerySucceeded method doesn't have its information unless you use this.collListItem which is passed during Function.createDelegate(this, this.onQuerySucceeded). Else you should define var collListItem; globally in ...


3

In this approach it is determined whether User belongs to specific Group and if so, then he/she is getting redirected to another page: function isUserMemberOfGroup(userId, groupId, success,error) { var ctx = SP.ClientContext.get_current(); var allGroups = ctx.get_web().get_siteGroups(); var group = allGroups.getById(groupId); ...


3

Most probably it occurs since List.TemplateType and ListTemplateFeatureId properties for a out-of-the-box Custom List (Feature ID:00BFEA71-DE22-43B2-A848-C05709900100) are passed instead of your custom List. How to determine List TemplateFeatureId and TemplateType properties TemplateType:the list of available List template types could be found on this ...


3

Referring directly the AssetPortalBrowser.aspx and getting the URL will be very much difficult, rather create an object and open the popup will be easier. Follow the below steps. I am getting the selected selected file in a text box and showing it in a alert. Go to Site Content > Site Assets Create a folder name Scripts Upload jquery-1.11.1.min.js and ...


3

Following code sample should help: SP.ViewCreationInformation viewCreationInformation = new SP.ViewCreationInformation(); viewCreationInformation.Title = "My View"; viewCreationInformation.ViewTypeKind = SP.ViewType.None; viewCreationInformation.RowLimit = 30; //Make sure that the name of the fields should be equal to 1 any of the associated SiteColumns ...



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