Tag Info

New answers tagged

0

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


0

You can get the value using REST service use following URL format http://SiteURL/_api/web/GetFolderByServerRelativeUrl('Shared%20Documents/fol1/fol2')/Files?$orderby=TimeLastModified desc function FetchAllFiles() { $.ajax({ url:"http://SiteURL/_api/web/GetFolderByServerRelativeUrl('Shared%20Documents/fol1/fol2')/Files?$orderby=TimeLastModified ...


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


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


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


0

The following example demonstrates how to access files in Document Set: SP.SOD.executeFunc('sp.js', 'SP.ClientContext', function() { var docSetUrl = '/Documents/2013'; //Document Set named 2013 in Documents library var ctx = SP.ClientContext.get_current(); var ds = ctx.get_web().getFolderByServerRelativeUrl(docSetUrl); ...


0

You are getting site collection groups earlier you are retrieving groups from the site collection, but when you execute your GetData() function, you are passing in a group name, but executing it at the root level. http://site/_api/web/sitegroups/getbyname('Owners')/users instead of http://site/subsite/_api/web/sitegroups/getbyname('Owners')/users


0

This should work: // the rest of your code omitted for brevity... uploadFile = documentLibrary.RootFolder.Files.Add(fileInfo); // Update the file metadata uploadFile.ListItemAllFields["ContentTypeId"] = contentTypeId; uploadFile.ListItemAllFields.Update(); clientContext.ExecuteQuery();


0

The problem depends on a lot of details like the authentication configuration of both systems (SP2010 and SP2013) and also the client. If we are talking about Internet Explorer, the authentication is only available within the browser request. That is at least one reason why Microsoft removed the sign in as feature. If you do a sign in as and click on a word ...


0

Don't you have cross-site scripting promlems, when accessing the SP 2013 site from the JavaScript on your SP 2010 page? Regarding your original problem, I inserted the following JavaScript code into a SharePoint 2010 page: $(document).ready(function(){ $.support.cors = true; $.ajax({ url: "http://YourSP2013Server/_api/web/CurrentUser", ...


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


0

Same issue here. Use Windows PowerShell instead of the SharePoint Online Management Shell and it will run.


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


0

You may try to add an OrderBy clause to your CAML query, to order by ID. ID is a naturally indexed column in SP, so ordering by ID should help overcome the 5000 threshold. To be done maybe in conjonction with a RowLimit to avoid the timeout... <OrderBy><FieldRef Name='ID' Ascending='TRUE' /></OrderBy> That would make: query.ViewXml ...


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


0

Since SharePoint CSOM does not support the loading of sites within site collection, the following example demonstrates how to accomplish it: public static class SiteExtensions { public static List<Web> EnumAllWebs(this Site site, params Expression<Func<Web, object>>[] retrievals) { var ctx = site.Context; var ...


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


0

You should request for the root web var web = ctx.get_site().get_rootWeb(); ctx.load(web,'Include(Title)'); ctx.executeQueryAsync(...); SharePoint 2013 getting all webs in a given site collection including root web using JSOM


0

Unlike Custom List, Document Library requires a File to be uploaded. This File will have a list item and you can set the metadata properties like Title. First you need to get the file that you want to upload. For that you can use <input id="inputFile" type="file" /> <input id="uploadDocumentButton" type="Button" value="Upload Document"/> Now ...


0

I fix it by switching to use Rest API :) var fileContentUrl = appweburl + "/_api/web/GetFolderByServerRelativeUrl('" + finalFolderUrl + "')/Files('" + fileName + "')/$value"; var info = { url: fileContentUrl, method: "GET", //headers: { "Accept": "application/json; odata=verbose", "X-RequestDigest": ...


0

Sahil Malik has Written a blog post on how to "Get list of site collections using CSOM in Office365", It may help you. Below is the code snippet from his blog: var token = TokenHelper.GetAppOnlyAccessToken("00000003-0000-0ff1-ce00-000000000000", tenantAdminUri.Authority, null).AccessToken; using (var clientContext = ...


0

Try this camlQuery.set_viewXml('<View><Query><Where><Eq><FieldRef Name=\'Approval Status\'/><Value Type=\'Text\'>Approved</Value></Eq></Where></Query></View>');


0

Your problem is the field XML, it should look like this: <Field Type="Choice" Name="ApprovalStatus" DisplayName="Approval Status"><CHOICES><CHOICE>Pending</CHOICE><CHOICE>Approved</CHOICE><CHOICE>Reject‌​ed</CHOICE></CHOICES></Field>


0

You can do this using below changes viewInfo.set_viewTypeKind(524288); viewInfo.set_setAsDefaultView(true); //set the view to default For a list of viewTypeKind refer link https://msdn.microsoft.com/en-us/library/office/jj245733.aspx Also in your code you should change context.load(viewcollection); with hostcontext.load(viewcollection);


0

I think your problem is that the variable sublistItems is re-assigned multiple times (in a while loop), so when onFilterQuerySucceeded is called the variable is most likely replaced with another value, which is not yet loaded. One way to solve this is to pass sublistItems into onFilterQuerySucceeded as an argument.


0

Try sample below <script type="text/ecmascript"> var clientContext = new SP.ClientContext.get_current(); var oWebsite = clientContext.get_web(); //Geting reference to the list oList = clientContext.get_web().get_lists().getByTitle('CustomList'); // Get filed collection var fldCollection = oList.get_fields(); var f2 = ...


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


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


0

Have you tried using Get-SPODeletedSite, and if you found anything there run the Remove-SPODeletedSite? This should surely remove any deleted site making the URL available for a new site. But there may still be references which needs to be removed by a Timer Job. These timer jobs are unfortunately inaccessible to us, and I usually wait to the next hour ...


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


0

In the client object model, the list groups in a site-collection needs to be fetched first and then based on the groups another call needs to be made to SharePoint Online to get the list of users. The following code snippet explains it all. namespace GetUsersInGroupCSOM { class Program { static void Main(string[] args) { ...


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"


0

Finally, I found this: http://www.lifeonplanetgroove.com/accessing-mixed-mode-sharepoint-web-applications-with-csom-and-powershell/ https://msdn.microsoft.com/en-us/library/office/hh124553%28v=office.14%29.aspx Basically, we need to use an event handler to add an HTTP Header to the request and force Windows Authentication. Otherwise, SP will redirect to ...


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


0

Most probably in the first example the error occurs due to the line shown below: folderItem.Update(); ctx.Load(folder); //<-loading of folder that has been moved! ctx.ExecuteQuery(); Depending on the SharePoint version you could consider the following examples for renaming of folder. SharePoint 2010 public static class FolderExtensions { ...


0

You hardly can authenticate with X-FormDigest, even if that part is mandatory for POST methods. You really need the user token and add a Bearer Header to your HTTP request headers: { ... "Authorization": "Bearer " + UserOrAppToken ... }, If you're not able to get user token, you can use the AppOnly token with ClientID and ...


0

You need to get the folder item. I don't think you can get the item directly from folder, but you can get it from the list. Example: public static void Rename(ClientContext ctx, List list, String oldName, String newName) { const string queryFormat = "<View Scope='RecursiveAll'><Query><Where>" + ...


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


0

The example demonstrates how to specify list item properties (Content Type in this case) while uploading the file: var targetList = context.Web.Lists.GetByTitle(listTitle); var fileInfo = new FileCreationInformation() { Content = fileContent, Overwrite = true, Url = fileUrl }; var uploadFile = ...


0

You need to generate SP.Context of the root web. You can use syntax clientContext = new SP.ClientContext(rootWebUrl);


0

According to Vesa (heading up Patterns and Practices), you can set a property on the list (I believe you actually set it on the List's Root Folder: https://twitter.com/vesajuvonen/status/581498547700387840


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


0

For anyone interested, I ended up creating a view on each list (configSearch) I am building dynamic advanced filtering for. The view allows me/user to layout the fields in any order and accommodate the adding of new fields to the search pane as the list grows. When a user select a list to search, I pass the list name to the following function. Once the data ...


0

This is possible but in my opinion a hack. I wrote an article to discuss if this is a valid way to do it - Manipulating SharePoint UI over an IFrame to add missing clientside Features Here's the Code: //quite dirty hack but at this point the only possibility to set the AccessRequest mail via clientside function setAccessRequest(mail) { var iframe = ...


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

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


0

I guess you would need to get the View for the lists, rather than the columns of the list. That way the ordering will be in place. Look here: using CSOM to retrieve fields in a list in a view


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

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



Top 50 recent answers are included