microsoft / Dynamics365Commerce.Solutions

Repository for hosting the Dynamics 365 Commerce end to end sample solutions
Other
54 stars 26 forks source link

Typescript error - Cannot read properties of undefined #111

Closed vkommuri2897 closed 1 year ago

vkommuri2897 commented 1 year ago

Hi,

I am getting below error with my view model. I am providing view model code below. I am not getting error if i do not extend CustomViewControllerBase in view model. What is the right procedure here.

ERROR MESSAGE: Cannot read properties of undefined (reading 'CustomViewControllerBase') Evaluating https://localhost:446/POS/Extensions/CDSG.Commerce.InventItemBarcode/Views/PrintBarcode/PrintBarcodeViewModel.js Evaluating https://localhost:446/POS/Extensions/CDSG.Commerce.InventItemBarcode/Views/PrintBarcode/PrintBarcodeView.js Loading Extensions/CDSG.Commerce.InventItemBarcode/Views/PrintBarcode/PrintBarcodeView

Code: #################################### import Views from "PosApi/Create/Views"; import { ClientEntities } from "PosApi/Entities"; import { Entities } from "../../DataService/DataServiceEntities.g"; import { InventItemBarcodeController } from "../../DataService/DataServiceRequests.g"; //import ko from "knockout"; import { ObjectExtensions } from "PosApi/TypeExtensions";

export default class PrintBarcodeViewModel extends Views.CustomViewControllerBase {

//public title: ko.Observable<string>;    
public DataSource_ItemBarcodeList: Entities.InventItemBarcode[];

constructor(context: Views.ICustomViewControllerContext) {
    super(context);        
    //this.title = ko.observable("Product Order");
    this.DataSource_ItemBarcodeList = [];
    this.refreshList();
}

public refreshList(): Promise<void> {
    this.state.isProcessing = true;  
    let req: InventItemBarcodeController.GetInventItemBarcodeListRequest<InventItemBarcodeController.GetInventItemBarcodeListResponse>
        = new InventItemBarcodeController.GetInventItemBarcodeListRequest<InventItemBarcodeController.GetInventItemBarcodeListResponse>();
    return this.context.runtime.executeAsync(req).then((responseVar: ClientEntities.ICancelableDataResult<InventItemBarcodeController.GetInventItemBarcodeListResponse>): Promise<void> => {
        if (!responseVar.canceled) {
            this.DataSource_ItemBarcodeList = responseVar.data.result;
            this.state.isProcessing = false;  
            return Promise.resolve();  
        }
        else {
            this.state.isProcessing = false;  
            return Promise.resolve();  
        }
    });
}

/**
madyke commented 1 year ago

I discussed this with Luke, and it sounds like this was most likely resolved through other communication channels. If this is still an active issue, please let us know and we can re-open it and provide assistance.