Skip to main content
2 of 2
edited
Amal Hashim
  • 28.4k
  • 5
  • 32
  • 61

Why do I use load AFTER these portions of code?

Let's take for example the code below:

function createListItemProdus() {
    var clientContext = new SP.ClientContext.get_current();
    var oList = clientContext.get_web().get_lists().getByTitle('achizitii_produs');            
    var itemCreateInfo = new SP.ListItemCreationInformation();
    this.oListItem = oList.addItem(itemCreateInfo);
    oListItem.set_item('name', some_value);           
    oListItem.update();    
    clientContext.load(oListItem);
    clientContext.executeQueryAsync(
        Function.createDelegate(this, this.onQuerySucceededGol), 
        Function.createDelegate(this, this.onQueryFailed)
    );
}

From what I've read on the Internet, the load function loads the content of the list from the server to the client.

Then why do I use clientContext.load(oListItem); after oListItem.set_item?

bloomingsmilez
  • 567
  • 6
  • 14
  • 29