I have a custom control that is on the transaction page. It needs to show the name of the person that is logged in.
I saw in FiscalizationManager.ts which triggers to use. The StaffID I pass in has a value and I can confirm that it is the ID I logged in with, but it returns a null for the Employee record.
Here is my typescript file:
***
CartViewCustomControlBase,
ICartViewCustomControlState,
ICartViewCustomControlContext,
CartChangedData
} from "PosApi/Extend/Views/CartView";
GetLoggedOnEmployeeClientRequest, GetLoggedOnEmployeeClientResponse
} from "PosApi/Consume/Employees";
import { IExtensionContext } from "PosApi/Framework/ExtensionContext";
import { IRuntime } from "PosApi/Framework/Runtime";
import { StringExtensions } from "PosApi/TypeExtensions";
import { ProxyEntities, ClientEntities } from "PosApi/Entities";
private static readonly TEMPLATE_ID: string = "ExtCartCustDetailControl";
public readonly pGrpHolder: Computed<string>;
public readonly salesTakerHolder: Computed<string>;
private readonly _employee: Observable<ProxyEntities.Employee>;
super(id, context);
this._employee = ko.observable(null);
//this.isVisible = true;
if (this.isCustomerSelected()) {
return this._customer().CustomerGroup;
}
});
if (this.isCustomerSelected()) {
return this._customer().PriceGroup;
}
});
return ObjectExtensions.isNullOrUndefined(this._employee()) ? StringExtensions.EMPTY : this._employee().Name;
});
this._customer(data.customer);
};
}
this._customer(state.customer);
}
public onReady(element: HTMLElement): void {
ko.applyBindingsToNode(element, {
template: {
name: CartCustDetailsControl.TEMPLATE_ID,
data: this
}
});
private GetEmployee(_StaffId: string): Promise <ProxyEntities.Employee[]>{
.then((response: ClientEntities.ICancelableDataResult<GetLoggedOnEmployeeClientResponse>): ProxyEntities.Employee => {
return response.data.result;
})
.catch(() => {
return null;
});
}
***
Can anybody help me figure out why GetEmployee is returning a null employee record instead of the actual record?
Any help is much appreciated