Tag Info

Hot answers tagged

3

The reason this is happening is because of the asynchronous nature of Javascript client object model. The statement after the function does not wait for the function to complete. In order to avoid this you can use deferreds/promises. UPDATE Callback Example of your code: myCallerFunction('abc', function (terms) { var termEnumerator = ...


3

Please see below code for getting all terms in a termset by using termsetid. The Key thing is making sure SP.js,sp.runtime.js and sp.taxonomy.js are loaded before you make a call to taxonomy store. $(document).ready(function () { //This makes sure all necessary Js files are loaded before you call taxonomy store ...


2

Your speculation is correct, the example provided in the question is intended for creating a wiki page and not enterprise wiki publishing page. Since you mentioned in your question JavaScript Object Model (JSOM), the below example demonstrates how to create enterprise wiki page via JSOM in SharePoint 2013. How to create enterprise wiki page using ...


2

This Code perfectly works on SharePoint 2013. References To be added: <SharePoint:ScriptLink name="clientforms.js" runat="server" LoadAfterUI="true" Localizable="false"/> <SharePoint:ScriptLink name="clientpeoplepicker.js" runat="server" LoadAfterUI="true" Localizable="false"/> <SharePoint:ScriptLink name="autofill.js" runat="server" ...


2

Some recommendations: 1) Avoid using global variables. Consider to pass parameters as function arguments, for example: function setLike(listId,itemId,like,success,error) { var ctx = SP.ClientContext.get_current(); Microsoft.Office.Server.ReputationModel.Reputation.setLike(ctx,listId,itemId, like); ctx.executeQueryAsync( function () { ...


2

Your understanding is right. If the code is written in client side technologies like JSOM or REST in a a visual webpart, it will later be easier to port to app model. This type of code can be put directly inside the SharePoint pages also using web parts like CEWP or Script Editor.


2

Function LoadMultiple has the following signature: function LoadMultipleSods(keys, fn, bSync) where the first argument accepts the array of SOD keys, RegisterSod function is used for registering JS function. Most probably in your case the registration of ps.js library is missing. In order to load ps.js library it has to be registered first and then could ...


2

You can use JavaScript call backs or Promises/deferreds to work synchronously with JavaScript client object model. CallBack Example: $(document).ready(function () { //don't exectute any jsom until sp.js file has loaded. SP.SOD.executeFunc('sp.js', 'SP.ClientContext', prepareTables); }); function prepareTables() { ...


2

Try this clntCntxt.Load(newFile); clntCntxt.ExecuteQuery(); //check out to make sure not to create multiple versions newFile.CheckOut(); ListItem newFileItem = newFile.ListItemAllFields; newFileItem["MyComments"] = "test"; newFileItem.Update(); // use OverwriteCheckIn type to make sure not to create multiple versions newFile.CheckIn(string.Empty, ...


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


1

The URL of SPList object is read only property. And you can't set a new URL to it. The best option you can have is to delete the existing list and create a new one.


1

I'm afraid not... The CSOM does not provide a mechanism for querying data across multiple lists that are not associated by a lookup field. In other words, there is no client-side functional equivalent of the SPSiteDataQuery class. If you need to perform a cross-list query from client-side code, consider creating a list view on the server that ...


1

Since you have Append Changes enabled you'll get back null as you've found. Here's an example of using SPServices to get what you need: ...


1

You would not use a CAML query to do that. You can get the selected items using SP.ListOperations.Selection.getSelectedItems(ctx) var ctx = SP.ClientContext.get_current(); var items = SP.ListOperation.Selection.getSelectedItems(ctx); See this related answer.


1

After error analysis I found out that the error was caused by calling improperly the item property. Item[Property] instead of Item.Property Little things make you happy :) Please find below the working code as jagged array seems not to be a feasible solution: if(! $change.IsPropertyAvailable("ItemId")) { $change | Add-Member ItemId("Not Applicable")} else ...


1

SP.Taxonomy.TermStore.getTerms Method could be utilized for finding Term in TermStore. The following example demonstrates how to find a Term by Label using JSOM: function findTermsByLabel(label,success,error) { var ctx = SP.ClientContext.get_current(); var ts = SP.Taxonomy.TaxonomySession.getTaxonomySession(ctx); var matchInfo = new ...


1

Yes, the event item is only one. However, it spans those timings which are mentioned in recurrence. If you go into List ribbon settings, you may find a view named "All Events". Click on this view and you should be able to see only one item for this recurrence.


1

I modified your code. Here is the working example. Note that the name of the view in my Tasks list is "All Tasks" function getItemsFromView(listTitle, viewTitle) { var context = new SP.ClientContext.get_current(); var list = context.get_web().get_lists().getByTitle(listTitle); var view = list.get_views().getByTitle(viewTitle); ...


1

The problem is that your functions don't exist when the line at the bottom calling getItemsFromView() executes as the code is waiting for sp.js to load. Instead remove the sp.sod.executeFunc from around your functions getItemsFromView and getItemsFromList and wrap it around your code at the bottom that way you only have to write that code once and your ...


1

Use SP.Taxonomy.Term.move Method to move the current Term object to be a child of a different Term. Example function moveTerm(sourceTermId,targetTermId,success,error) { var ctx = SP.ClientContext.get_current(); var ts = SP.Taxonomy.TaxonomySession.getTaxonomySession(ctx); var termStore = ts.getDefaultSiteCollectionTermStore(); var ...


1

SP.Taxonomy.TermSetItem.reuseTerm function has the following signature: function SP.Taxonomy.TermSetItem.reuseTerm(sourceTerm,reuseBranch) Parameters sourceTerm Type: SP.Taxonomy.Term The source Term for the reused Term reuseBranch Type: Boolean Reuse the TermSetItem and its child Terms creates a new reused Term object below this TaxonomyItem ...


1

Maybe try internal name of the column, Total_x0020_Events. Space is replaced with _x0020_ in Internal names.. Otherwise you can go to List settings -> Under columns click Total Events and check the Field name in URL. That is the internal name of the column.


1

In your example the methods: SP.ClientContext.load that prepares the query SP.ClientContext.executeQueryAsync that executes the query are missing. The following example demonstrates how to retrieve TermSet by its name: SP.SOD.registerSod('SP.ClientContext', SP.Utilities.Utility.getLayoutsPageUrl('sp.js')); ...


1

Follow this article, will help you : http://www.vrdmn.com/2012/12/working-with-taxonomy-and-javascript-in.html as well look at the below code to access the terms: function execOperation(){ //Current Context var context = SP.ClientContext.get_current(); //Current Taxonomy Session var taxSession = ...


1

You could utilize SP.FileVersionCollection.deleteAll Method for that purpose: Example var fileName = '/sites/news/Pages/default.aspx'; var ctx = SP.ClientContext.get_current(); var versions = ctx.get_web().getFileByServerRelativeUrl(fileName).get_versions(); versions.deleteAll(); ctx.executeQueryAsync( function() { console.log('File versions ...


1

In the end I did it like this, although I think Vadim's approach may also be correct, I couldn't get it to work myself. get user id by name function getUserId = function (userName) { var clientContext = SP.ClientContext.get_current(); var web = clientContext.get_web(); var currentUser = web.ensureUser(userName); ...


1

You could utilize SP.FieldUserValue.fromUser Method for that purpose, for example: var authorVal = SP.FieldUserValue.fromUser(userName); listItem.set_item('Author', authorVal); Complete example var properties = {}; properties['Title'] = 'Request N#789'; properties['Author'] = ...


1

Updating this field requires the UpdateOverwriteVersion method when working on the server side (see sample). Since this method (or the SystemUpdate method) is not available in the client OM, I am a bit sceptic that you can achieve your goal. It's not clear, what you would like to achieve with this code: var userField = user.get_id() + ";#" + ...


1

How to determine whether site is a Publishing site using CSOM: public static bool IsPublishingWeb(Web web) { var ctx = web.Context; var propName = "__PublishingFeatureActivated"; //Ensure web properties are loaded if (!web.IsObjectPropertyInstantiated("AllProperties")) { ctx.Load(web, w => w.AllProperties); ...


1

I've used quite some time to get around a similar issue in regards to the Search API. Over and over again I was troubled with the following error-message: "Object doesn't support this action" Try to add a reference/key to "Microsoft.SharePoint.Client.Search.Query.KeywordQuery" instead of "Microsoft.SharePoint.Client.Search.Query". At least that worked for ...



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