question

MohammadQasim-1438 avatar image
0 Votes"
MohammadQasim-1438 asked MichaelHan-MSFT commented

How to call method , once delete method competed successfully using Jsom


i am using Jsom to delete mutiple items.

Poblem : once all items deleted then i want to execute insert method.

Solution Required: Just update me , where to call " insert method " , after completion of " delete operation " completed successfully. ?


Attached images are attached for code review

87773-deletedquery.png
87736-insertmethof.png


office-sharepoint-server-development
deletedquery.png (62.1 KiB)
insertmethof.png (38.9 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

MichaelHan-MSFT avatar image
0 Votes"
MichaelHan-MSFT answered MichaelHan-MSFT commented

Hi @MohammadQasim-1438,

You should put the "insert method" in the function onDeleteSucceeded to achieve this:

88026-image.png


If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



image.png (6.3 KiB)
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I believe, its called after every record , I mean, I am deleting multiple records, so its called after deletion of every single record ?

0 Votes 0 ·

Hi @MohammadQasim-1438,

In the function OnQuerySucceeded, you should put the method clientContext.executeQueryAsync() outside the while loop:

 function onQuerySucceed(sender,args,flag){
    
    
     while (listItemEnumerator.moveNext()) {
        
     }
     clientContext.executeQueryAsync();
     return flag;
    
 }
0 Votes 0 ·