0

I am trying to make each function of jquery asynchronous...In sharepoint framework, I am trying to update each line item of HTML table to sharepoint list using PnP JS Core library. For this I am trying below code:

 var itemID :any= $.when(async (result: number): Promise<any> => {
    var data = await getItemID();
    result = data[0].ID;
    return result;
}).then(() =>{
web.lists.getByTitle("TravelRequestDetails").items.getById(itemID).update({
   "Cost": cost
    })
  })

In the above code getItemID() is not getting called and then is executed due to which itemID is coming 'undefined'....

Please suggest any workaround for the same...

2
0

You can try creating a async function and later invoking it

async function doSomething(){
//....do something
var result = await getItemID();
 return result[0].ID 
}

//some
var itemID = await doSomething()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.