I have been reading alot and trying to assign value of a promise to variable outside function but still wasn't able to find exact example how to solve it in my case. I might be stupid but reading about sync/asynch doesn't really help me. Seems like there strictly problem with getting value from a promise or something...
What should be added to following code to make it able to assign value to variable?
var mainInvoiceID = "";
function retrieveRowsInvoices() {
const resultsRowsInvoices = Xrm.WebApi.retrieveMultipleRecords("new_rowsinvoices", filterRowsInvoices);
return resultsRowsInvoices;
}
retrieveRowsInvoices().then(function(result) {
let rows = result.entities[0]._new_idinvoice_value;
console.log(rows);
mainInvoiceID = rows;
});