Tag Info

Hot answers tagged

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

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

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

I am using below code for past year or so SP.SOD.executeOrDelayUntilScriptLoaded(Function.createDelegate(this, function() { 'use strict'; var taxonomySodLoaded = false; if (typeof(_v_dictSod) !== 'undefined' && _v_dictSod['sp.taxonomy.js'] == null) { SP.SOD.registerSod('sp.taxonomy.js', ...


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

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

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

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

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

If you have a document library use: JSOM: .get_file().get_versions() REST: ../File/Versions However if you have a normal list this won't work, but instead you can request the item file directly. This is a hack and I can't guarantee future support: var itemFileUrl = _spPageContextInfo.webServerRelativeUrl + "Lists/" + listName + "/" + itemId + ...


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


1

You can simply invoke a REST call to following URL /_api/lists/getByTitle('ListTitle')/getItemById(1)/AttachmentFiles/getByFileName('filename') Then check the response to see if file exists or not. JSOM function onSuccess(sender, args) { var item = listItem; var total = item.get_attachmentFiles().get_count(); if (total > 0) { ...


1

There is no such property in field object, fields are sorted in List Settings page by title if Content Types are enabled as demonstrates the following example. Example function getListFields(listTitle,success,failure) { var ctx = SP.ClientContext.get_current(); var list = ctx.get_web().get_lists().getByTitle(listTitle); var fields = ...


1

This is happening because you haven't explicitly requested for Parent Id. Try including that in the load statement 'Include(IsRoot, Labels, TermsCount, CustomSortOrder, Id, IsAvailableForTagging, Name, PathOfTerm, Parent, Parent.Id, TermSet.Name)' You should check whether the current term is root or not as follows if(currentTerm.get_isRoot() == false) { ...


1

I was running into the same issues and it turned out I was referencing the wrong DLLs. I was also having issues with CreatePersonalSiteEnqueueBulk not being recognized. I was referencing the 15 version not the 16 version and also the 16 version I had was out of date. Be sure you are referencing the proper DLL and have the most up to date version. I'm now ...


1

If I understand your question correctly, you want to retreive user profile properties via CSOM or REST. Yes this is possible. You need to refer SP.UserProfiles.js in your javascript file and after that you can use the following code to fetch the properties. The code is taken from msdn site referred below: var personProperties; // Ensure that the ...



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