6

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


4

As said on Twitter. You could first create an empty element with a specific ID. Pass that ID with your ajax call, and once you retrieved the information from your ajax call, you could retrieve the empty element and pass the necessary information in it. This is probably the easiest and quickest way to achieve it.


3

First, I'm guessing that the log of Display of all incidents for... is happening multiple times because it is on the same line as the closing bracket of the inner while loop. Try moving that down to the next line. And what do you mean it doesn't filter by Issue title? In your last few log examples, Incident #1 and Incident #2 both have the same last issue ...


3

You don't necessarily need to use a promise here, just don't try to set the value of the HTML element until after you get your result. So in your default.aspx: <asp:Label id="LabelA" runat="server" Text="0"></asp:Label> <script type="text/javascript"> // just kick off the asynchronous call getVerificheCount('ListTitle','StatusNotOk'); &...


3

Yes, you need to make 3 REST calls. One for checking out the item, second for updating the item, third for checking in the item. I presume you know that you actually need to make another REST call before all these 3, a call to retrieve the Form Digest Value from the context info of the site where the item is located. The REST URI structure for checkouts ...


3

You have the right idea, and I went ahead and cleaned up the structure. In general, the goal of promises is to make asynchronous programming more like procedural programming. In general, you'll have a structure of x().then(function(a) { return y(a); }).then(function(b) { return z(b); }) // ... where data from asynchronous call x() feeds into async ...


2

As a workaround, you could fetch the information before the user gets to your list view and store it in sessionStorage... Make the calls to find out if your user is in whatever groups you're trying to look at, then put the result in the sessionStorage object with something like sessionStorage.isInMySpecialGroup = "true" // sessionStorage only wants strings ...


2

// Run your custom code when the DOM is ready. $(document).ready(function () { initializePeoplePicker('peoplePickerDiv'); }); // Render and initialize the client-side People Picker. function initializePeoplePicker(peoplePickerElementId) { // Create a schema to store picker properties, and set the properties. var schema = {}; schema['...


2

JQuery AJAX does not use native JS promises. You can observe this by the way they defined a success and error callback. You can explore using fetch https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API, which is a reasonable browser API since you are already using Promise. I'll provide examples for both fetch and ajax: /** @returns {Promise.<...


2

Here's an example of how to wrap a JSOM call in a jQuery promise. You should be able to modify the code above to use the same calling pattern. function getListsCsomJquery(rowLimit) { var dfd = jQuery.Deferred(); var context = SP.ClientContext.get_current(); var web = context.get_web(); var lists = web.get_lists(); var listsArray = ...


2

ctx.executeQueryAsync(function() { dfd.resolve(onQuerySucceeded); },onQueryFailed); Closely read what you are doing here: You are (immediatly) resolving a Promise with a Function declaration, Move that resolve to your onQuerySucceeded function with something like if (j===6) dfd.resolve(); Notes I do not see proper var declaration of dfd, so if it ...


2

Not entirely sure how you initialize the deferred function calls, but $.when.apply is the key here. var promises = []; var rows = e.target.result.split("\n"); for (var i = 0; i < rows.length; i++) { if(rows[i]) { promises.push(addCompanyItem(rows[i])); // store as list item in SharePoint } } $.when.apply($, promises).then(...


1

You can use Promises and Deferreds to implement the asynchronous nature in the call. This way the table building activity will start only after fetching the list items. The Skeleton of the call is shared below. You can add the logic appropriately. var listData = []; function getListItems() { var dfd = $.Deferred(); $().SPServices({ operation: "...


1

My starting point is to have one shared instance of SP.ClientContext. I'm going to augment the object instance so using new keyword is preferable: var ctx = new SP.ClientContext(); The basic theory is to create a method execThen returning a promise, called when executeQueryAsync finishes, but only once for each "listener". Something like this: Usage ctx....


1

As your restHelper.peopleSearchQuery(options);is a promise, you can call that function and add a then() which in turn calls drawUserData restHelper.peopleSearchQuery(options).then(drawUserData);


1

At first glance (and its late saturday afternoon here, and the sun is out and its above 20 celcius for the first time, and I have had some beer) You are running into JavaScrip scoping issues: var passedData = { dfd: d, idx: i }; is the line that worries me, (it is almost a philosophical question... but that must be the beer) where does i come from? You ...


1

I'm not sure what you mean with freeze, but I can't see where you call or close the "working on it". I made simple example with dummy code, maybe it will help you. Because I have never seen that async calls have locked the UI etc, so you could try this approach: SP.UI.ModalDialog.showWaitScreenWithNoClose("title", "message", 400, 400); var ...


1

We have used Spin.js in several such scenarios. Usage Define a <div> in the HTML markup <div id="userTableSpinner"></div> Then in Javascript code find the div and start spinner and finally stop it once all processing is done: var userTableSpinner; function someProcessStartsHere() { if (userTableSpinner == null) { userTableSpinner = ...


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