As I try to make sense of this code, something seems off. It appears to be a straightforward portion of a promise chain.
let flightName = [];
let guidArr = [];
Promise.all(guidArr)
.then(values => {
for(var a = 0; a < values.length; a++) {
Xrm.WebApi
.online
.retrieveRecord("crd80_flightplanevent", values[a], "?$select=_crd80_learnerflight_value")
.then(
function success(result) {
flightName.push(result["_crd80_learnerflight_value@OData.Community.Display.V1.FormattedValue"])
},
function(error) {
DisplayError(error)
});
}
return flightName
}).then(flightName => {
console.log(flightName)
console.log(flightName.length)
return flightName
})
https://i.sstatic.net/3so2V.jpg
The flightName array is correctly displayed in the console, but strangely, the length of flightName always shows as 0 despite the output showing a length of 2 when using console.log(flightName)
What could be causing this discrepancy? I am trying to access each item in the array but it doesn't seem to be working as expected