Tag Info

New answers tagged

0

Try this: FileCreationInformation fci = new FileCreationInformation(); fci.Content = newFile.Bytes; fci.Url = sourceFile.Url; fci.Overwrite = true; Microsoft.SharePoint.Client.File replacedFile = list.RootFolder.Files.Add(fci); context.Load(replacedFile); context.ExecuteQuery();


1

The following example demonstrates how to update enterprise wiki page content: function updateWikiPage(pageUrl,pageContent,success,error) { getFileWithProperties(pageUrl, function(file){ var listItem = file.get_listItemAllFields(); var itemProperties = {'PublishingPageContent': pageContent}; ...


2

Ok, thanks for all the help everyone. It was a good insight into how to go about doing what I wanted. The closest way I could get to 'almost' work was Francoise Becker's idea using SPServices jQuery library, however I think ive discovered that in the DISPFORM.aspx, the code behind is different to other pages as I couldnt get the code to run when the ...


1

As Dylan Cristy suggested, you'll need to execute a CAML query to pull back just the items where the Title field is equal to the value you're looking for. Here's the syntax for doing that in the JavaScript client side object model: var title = "My Item Title"; // the title of the item you're looking for var ctx = SP.ClientContext.get_current(); this.web = ...


1

Step 1: If you haven't got SPServices, get it -- it's free and it'll make your life easier. http://spservices.codeplex.com/ Step 2: Here's what I've used to get the ID (assuming Title is unique): // Define a lookup query that will pull only the records where the Title field is the one we are looking for var queryLookup = ...


1

The lookup field in SharePoint internally always looks like ID;#Value example 10;#ItTeam So in field 'Article' You already have ID of target element in 'Department'. So You should parse it using jQuery getter(or see how Your existing JS function does it), and query ListItem element by this Id.


3

Based on your question, i understand that you want to get ID of Department item which is referenced in Article list. Correct me if i am wrong. To get ID of lookup list item, include following in you code(Assuming field name of lookup field from Department is "Department" in article list : var childIdField = listItem["Department"] as FieldLookupValue; if ...


3

One thing you can do is use SP.List.getItems(query) to query the 'Department' list for the item with the Title value you want. Once you get the list item, you can get its ID. (Keep in mind that the getItems(query) method will return a list item collection, even though that collection may only contain one item.) Your CAML query would look something like ...


0

Using 'new' is definitely required, as suggested by wjervis: var context = new SP.ClientContext(currentUrl);


0

Sorry to bother ! Found that, runtime reference of sp.js : sp.runtime.js was missing in code. <script type="text/javascript" src="/_layouts/15/sp.runtime.js"></script> So after I added the reference before sp.workmanagement.js, it worked ! ☺


0

I was able to get this working if my lookup has less tahn 20 items. However it is not working if i has more than 20 + items in Ie10. function ResetDropDownList(lookupcolumnName,NumStoreColName) { if(getField('select',lookupcolumnName)) { getField('input',NumStoreColName).value=''; $("select[title='"+ lookupcolumnName +"'] ...


3

The following example demonstrates how to return web sites sorted by last modified date: function getWebs(success,error) { var ctx = SP.ClientContext.get_current(); var web = ctx.get_web(); var webs = web.getSubwebsForCurrentUser(null); ctx.load(webs); ctx.executeQueryAsync( function(){ var result = []; ...


-1

Not sure that YQL would solve it. As below sample var site = url; //Cross Domain URL goes here var yql = 'http://query.yahooapis.com/v1/public/yql?q=' + encodeURIComponent('select * from xml where url="' + site + '"') + '&format=xml&callback=?'; // Request that YSQL string, and run a callback function. // Pass a defined function to prevent ...


0

Firstly, if your code is in SharePoint site, there is no need of giving script refernce., because, sp.js will be already included in the Master Page. Infact you can use this as below sample function successHandler(data, textStatus, jqXHR) { SP.UI.Notify.addNotification("Created Successully", false); }


-1

Check if your list does have attachments enabled? This can be done using Rest API /getByTitle('<ListName>')/items?$filter=substringof('Item', Title) &$select=AttachmentFiles,Title&$expand=AttachmentFiles&$top=4&$orderby=Title"


1

You can do it in Singleline of code var siteCollectionURL = _spPageContextInfo.siteAbsoluteUrl;


3

Using SharePoint 2010 JSOM i would suggest the following approach to retrieve list item attachments: determine whether List Item contains attachments or not via ListItem.Attachments property in case if list List Item contains attachments, submit a second request to retrieve attachment files Example function ...


1

You are committing one Cardinal Sin of .NET programming; you are deleting items of a collection in a foreach loop. When you delete an item in a loop like this, you are changing the collection that's being iterated, but the foreach loop still attempts to iterate as if the collection was still in its original state, and eventually the enumerator get out of ...


0

In my answer I assume you use SP 2013 (see the path including '15'). So if you define the format function for the String object as (see source here): String.format = (function () { // The string containing the format items (e.g. "{0}") // will and always has to be the first argument. var theString = arguments[0]; // start with the second ...


0

Here's a quicker way with SharePoint 2013: function CheckCurrentUserMembership() { var clientContext = new SP.ClientContext.get_current(); this.currentUser = clientContext.get_web().get_currentUser(); clientContext.load(this.currentUser); this.userGroups = this.currentUser.get_groups(); clientContext.load(this.userGroups); ...


0

All you have to do is refer to "sp.js" file provided by the sharepoint if sharepoint : 2010: <SharePoint:ScriptLink ID="ScriptLink1" runat="server" Name="sp.js" OnDemand="false" Localizable="false" LoadAfterUI="true"/> or <script src="/_layouts/sp.js" type="text/javascript"></script> <script src="/_layouts/SP.UI.Dialog.js" ...


0

Add the List View Web Part to a page, set the properties how you want them, and then export the XML using the web part's dropdown menu. If Export isn't included in the menu, change the Export Mode property (Advanced tab) of the Web Part.


-1

Just use Microsoft.Sharepoint.Client & Runtime Dlls of Version 16. You won't get this error. Stackoverflow link


2

How to retrieve all web sites under a site collection using SharePoint JSOM The following function demonstrates how to recursively retrieve all sub sites: function getAllWebs(success,error) { var ctx = SP.ClientContext.get_current(); var web = ctx.get_site().get_rootWeb(); var result = []; var level = 0; var getAllWebsInner = ...



Top 50 recent answers are included