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
  • is this a javascript or React webpart? Commented Aug 28, 2020 at 7:31
  • javascript webpart Commented Aug 28, 2020 at 11:18

1 Answer 1

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 and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.