I need to get the employee's name to show in the search order view grid (OrderSearchViewColumns.ts) as a column.
Here Oksana helped me to get the value from the employee request/response pair on a typescript file that shows just fields:
https://community.dynamics.com/365/commerce/f/dynamics-365-commerce-forum/380463/how-to-find-employee-record-in-custom-control
How do I add it to a column grid?
Here is my attempt:
****
export default (context: ICustomColumnsContext): IOrdersListColumn[] => {
return [
{
title: context.resources.getString("tmc_20"), //"SALES ORDER",
computeValue: (row: ClientEntities.ISalesOrderDetails): string => {
return row.salesOrder.SalesId;
},
ratio: 10,
collapseOrder: 8,
minWidth: 100
},
{
title: context.resources.getString("tmc_41"), // "SALES TAKER",
computeValue: (row: ClientEntities.ISalesOrderDetails): string => {
if (!ObjectExtensions.isNullOrUndefined(row.salesOrder.StaffId)) {
let runtime: IRuntime = context.runtime;
return runtime.executeAsync(new GetLoggedOnEmployeeClientRequest(row.salesOrder.StaffId))
.then((response: ClientEntities.ICancelableDataResult<GetLoggedOnEmployeeClientResponse>): ProxyEntities.Employee => {
return response.data.result;
})
.then((results: ClientEntities.ICancelableDataResult<ProxyEntities.Employee>): ProxyEntities.Employee => {
return results.data;
})
.then((empl: ProxyEntities.Employee): string => {
return empl.Name;
})
.catch(() => {
return StringExtensions.EMPTY;
});
}
return StringExtensions.EMPTY;
},
ratio: 10,
collapseOrder: 6,
minWidth: 100
},
...
...
...
...
****
I get this error however:

The first "then" receives the promise. The 2nd "then" is supposed to receive the actual employee record and then the 3rd "then" is supposed to retrieve the name on the employee record. This is how I understood the promise is working. But it seems I am still not understanding how Promise is working because I just can't get to the actual record.
Any help is much appreciated.