Tag Info

Hot answers tagged

4

You are missing a couple of rows in a working script. First, after setting the oList variable you need to load it: clientContext.load(oList); Then you need to fetch the value by calling: clientContext.executeQueryAsync( Function.createDelegate(this, onQuerySucceeded), Function.createDelegate(this, onQueryFailed) ); Now, you need to create the ...


3

You could consider the following modified example for enumerating all sites within site collection: function enumWebs(propertiesToRetrieve, success,error) { var ctx = SP.ClientContext.get_current(); var rootWeb = ctx.get_site().get_rootWeb(); var result = []; var level = 0; ctx.load(rootWeb,propertiesToRetrieve); result.push(rootWeb); ...


2

I might be wrong, but isnt Colleagues the same as SPS-Peers? If so you could get it with UserProfiles. Example: function getPeers() { var context = SP.ClientContext.get_current(); var peopleManager = new SP.UserProfiles.PeopleManager(context); userProfileProperties = peopleManager.getMyProperties(); context.load(userProfileProperties, ...


2

Are you doing this on-premise? I'm not sure this is supported on-prem yet! See details here: What about on-premises? Right now this capability was released only to the Office 365 side, but we are actively listening input from the customers and partners for following other actions. You can still continue using user profile web service in the ...


2

Most probably the error File not found occurs since you are trying to retrieve attachments folder that not yet exist in method HasListItemAttachment The following example demonstrates how to upload attachment file via SharePoint JSOM: function processUpload(fileInput, listTitle, itemId,success,error) { var reader = new FileReader(); reader.onload = ...


2

Evidently this error occurs in case if file has been modified while updating the file: listItem.Update(); ctx.ExecuteQuery(); How about this approach? public static File UploadFile(ClientContext ctx, string sourceFilePath, string targetUrl,IDictionary<string,string> fileProperties) { var targetFileUrl = String.Format("{0}/{1}", targetUrl, ...


2

You need to return the promise in the itemIsDuplicate() function, not the success callback. Just move return deferred.promise(); to the end of the function. You'll might want to either add deferred.resolve() to the error callback, or a deferred.reject() if you need to execute something after an error occurs. Code should be as such: function ...


2

You have to include the property: using (var clientContext = new ClientContext("http://yourSite/")) { var oSite = clientContext.Site; clientContext.Load(oSite); var oWeb = oSite.OpenWeb(""); clientContext.Load(oWeb, web => web.Lists); clientContext.ExecuteQuery(); //get your list by index var list = oWeb.Lists[0]; ...


2

If you want to send an email using CSOM (js) you can use this: function sendEmail(from, to, body, subject) { var siteurl = _spPageContextInfo.webServerRelativeUrl; var urlTemplate = siteurl + "/_api/SP.Utilities.Utility.SendEmail"; $.ajax({ contentType: 'application/json', url: urlTemplate, type: "POST", data: ...


1

You can use success handler for reading file content function readFileSuccess(data) { alert(data); } Update var executor = new SP.RequestExecutor(weburl); var info = { url: fileContentUrl, method: "GET", binaryStringResponseBody: true, success: function (data) { //binary data available in data.body var result = ...


1

How to set JSLink property using JSOM: function setupJsLink(pageUrl, wpId,jsLinkUrl,success,error) { var context = SP.ClientContext.get_current(); var page = context.get_web().getFileByServerRelativeUrl(pageUrl); var wpm = page.getLimitedWebPartManager(SP.WebParts.PersonalizationScope.shared); var webpartDef = wpm.get_webParts().getById(new ...


1

If your ultimate goal is to get SharePoint list items using JavaScript, then you can refer below set of functions. Also you can refer this useful msdn blog. function getListItems () { try { var clientContext = new SP.ClientContext('http://www.vignesh.cloudappsportal.com'); var oList = ...


1

Create a new RoleDefinitionBinding, object set the type of permissions to it and add it as parameter to RoleAssignments of list item: using System; using Microsoft.SharePoint.Client; using SP = Microsoft.SharePoint.Client; namespace Microsoft.SDK.SharePointServices.Samples { class BreakSecurityInheritanceAddUser { ...


1

AFAIK File class does not expose LinkingUrl property in SharePoint 2013 CSOM API (version 15.0.4420.1017) including the latest version April 2015 CU (15.0.4711.1000) Since File.LinkingUrl property returns an absolute file url, you could consider the following approach in SharePoint 2013 CSOM API: using (var ctx = ClientContext(webUri)) { var file = ...


1

Try this var context = new SP.ClientContext.get_current(); var web = context.get_web(); var list = web.get_lists().getByTitle("DocLibrary"); var query = new SP.CamlQuery(); var caml = "<View><Query><OrderBy><FieldRef Name='Modified' Ascending='FALSE' /></OrderBy></Query></View>"; ...


1

It is very possible look at the code provided by the office pnp team here: https://github.com/OfficeDev/PnP/blob/master/OfficeDevPnP.Core/OfficeDevPnP.Core/AppModelExtensions/TenantExtensions.cs#L414 public static void SetSiteProperties(this Tenant tenant, string siteFullUrl, string title = null, bool? allowSelfServiceUpgrade = null, ...


1

How to set property in List PropertyValue.FieldValues is read-only property, the following example demonstrates how to set property for a List: var list = ctx.Web.Lists.GetByTitle(listTitle); var listProperties = list.RootFolder.Properties; listProperties[key] = value; list.RootFolder.Update(); list.Context.ExecuteQuery(); How to load properties for a ...


1

Just want to add that you could pass the properties as an array, if you look at the definition for the load function: load: function SP_ClientRuntimeContext$load(clientObject) { if (!clientObject) { throw Error.argumentNull('clientObject'); } SP.ClientAction.$j(this, clientObject); var $v_0 = null; if ...


1

Unfortunately it does not seem possible to archive via SharePoint CSOM/JSOM API since SSOM ColleagueManager class is not supported in CSOM/JSOM API. But you could utilize SharePoint Web Services, in particular UserProfileService.GetUserColleagues method for that purpose: SPServices example: $().SPServices({ operation: "GetUserColleagues", ...


1

You could utilize Web.SiteUsers property to gets the all users that belong to the site collection. But since it returns all the users including system accounts, the following examples demonstrate how to return only real users. CSOM using (var ctx = GetContext(webUri,userName,password)) { var users = ctx.LoadQuery(ctx.Web.SiteUsers.Where(u => ...


1

Yes, You can get the list items using REST. url: http://site url/_api/web/lists/GetByTitle(‘Test')/items method: GET headers: Authorization: "Bearer " + accessToken accept: "application/json;odata=verbose" or "application/atom+xml"


1

You need to add Client Authentication Mode before the Credentials to check with which credential user is going to log in into that URL. ClientContext context = new ClientContext("http://mySPSite/sites/doc"); //This line is used for default Authentication context.AuthenticationMode = ClientAuthenticationMode.Default; //This line is used for Form Based ...



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