Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Uncaught TypeError: Cannot read properties of undefined (reading 'fetchData')

    SmartClient Version: v12.1p_2021-05-22/LGPL Deployment (built 2021-05-22)
    Google Chrome Version 101.0.4951.64 (Official Build) (64-bit)

    When I make a click on tab, it should fetch list. I see those requests happen:

    https://sc-php:4433/backend/smartcli...5-22&isc_xhr=1

    Form data:
    1. command:
      System\Command\ErrorLogger\LogErrorCommand
    2. arguments:
      {"errorMessage":"Error: Uncaught TypeError: Cannot read properties of undefined (reading 'fetchData')\n Url: https://sc-php:4433/smartclient/syst.../ISC_Core.js\n Line number: 56759\n Stacktrace: TypeError: Cannot read properties of undefined (reading 'fetchData')\n at InvoiceAdHocChargesTab.load (https://sc-php:4433/js/application.js?v=$$$SYSTEM_VERSION$$$:28321:54)\n at CallbackImpl.<anonymous> (https://sc-php:4433/js/application.js?v=$$$SYSTEM_VERSION$$$:28291:85)\n at https://sc-php:4433/js/application.js?v=$$$SYSTEM_VERSION$$$:10087:77\n at Function.m.each.m.forEach (https://sc-php:4433/js/libraries/und...n.js:5:2350)\n at CallbackImpl.fire (https://sc-php:4433/js/application.js?v=$$$SYSTEM_VERSION$$$:10087:15)\n at InvoiceAdHocChargesTab.Tab.__notifySelected (https://sc-php:4433/js/application.js?v=$$$SYSTEM_VERSION$$$:21128:51)\n at cons.tabSelected (https://sc-php:4433/js/application.js?v=$$$SYSTEM_VERSION$$$:21214:37)\n at cons._tabSelected (https://sc-php:4433/smartclient/syst...js:15189:18)\n at cons.buttonSelected (https://sc-php:4433/smartclient/syst...js:13350:36)\n at cons.setSelected (https://sc-php:4433/smartclient/syst...js:15606:59)\n at cons.select (https://sc-php:4433/smartclient/syst....js:3486:10)\n at cons.handleActivate (https://sc-php:4433/smartclient/syst....js:4681:14)\n at cons.handleClick (https://sc-php:4433/smartclient/syst....js:4721:17)\n at cons.invokeSuper (https://sc-php:4433/smartclient/syst....js:7187:44)\n at cons.Super (https://sc-php:4433/smartclient/syst....js:7005:21)\n at cons.tabDefaults.handleClick (https://sc-php:4433/smartclient/syst...s.js:543:21)\n at cons.bubbleEvent (https://sc-php:4433/smartclient/syst...js:55037:44)\n at cons.handleClick (https://sc-php:4433/smartclient/syst...js:52351:24)\n at cons._handleMouseUp (https://sc-php:4433/smartclient/syst...js:52036:54)\n at cons.handleMouseUp (https://sc-php:4433/smartclient/syst...js:51877:26)\n at cons.dispatch (https://sc-php:4433/smartclient/syst...js:56755:30)\n at HTMLDocument.eval (eval at isc__makeFunction (https://sc-php:4433/smartclient/syst...ore.js:2502:21), <anonymous>:3:127)"}
    3. isc_tnum:
      160
    Response:

    {"response":{"status":0,"data":{"success":true,"message":""}}}


    And https://sc-php:4433/backend/smartclient/apis

    Form data:

    data:
    [{"id":"s14","url":"/backend/smartclient/api","data":{"data":"{"invoice":-2}","_operationType":"fetch","_startRow":0,"_endRow":75,"_sortBy":"["-id"]","_useStrictJSON":false,"_textMatchStyle":"substring","_componentId":"isc_ListGrid_0","_dataSource":"Invoicing\\DataSource\\InvoiceRecordDataSource","isc_metaDataPrefix":"_","isc_dataFormat":"json"}}]

    Response:

    {"status":"ok","data":[{"id":"s16","data":"{\u0022response\u0022:{\u0022status\u0022:0,\u0022startRow\u0022:0,\u0022endRow\u0022:0,\u0022totalRows\u0022:0,\u0022data\u0022:[]}}"}]}

    Chrome console gives this error:

    ISC_Core.js:56759 Uncaught TypeError: Cannot read properties of undefined (reading 'fetchData')
    at InvoiceAdHocChargesTab.load (InvoiceAdHocChargesTab.ts:161:46)
    at CallbackImpl.<anonymous> (InvoiceAdHocChargesTab.ts:126:61)
    at Callback.ts:57:62
    at Function.m.each.m.forEach (underscore-min.js:5:2350)
    at CallbackImpl.fire (Callback.ts:57:15)
    at InvoiceAdHocChargesTab.Tab.__notifySelected (Tab.ts:73:51)
    at cons.tabSelected (TabSet.ts:84:37)
    at cons._tabSelected (ISC_Containers.js:15189:18)
    at cons.buttonSelected (ISC_Containers.js:13350:36)
    at cons.setSelected (ISC_Foundation.js:15606:59)
    at cons.select (ISC_Foundation.js:3486:10)
    at cons.handleActivate (ISC_Foundation.js:4681:14)
    at cons.handleClick (ISC_Foundation.js:4721:17)
    at cons.invokeSuper (ISC_Core.js:7187:44)
    at cons.Super (ISC_Core.js:7005:21)
    at cons.tabDefaults.handleClick (ISC_Containers.js:543:21)
    at cons.bubbleEvent (ISC_Core.js:55037:44)
    at cons.handleClick (ISC_Core.js:52351:24)
    at cons._handleMouseUp (ISC_Core.js:52036:54)
    at cons.handleMouseUp (ISC_Core.js:51877:26)
    at cons.dispatch (ISC_Core.js:56755:30)
    at HTMLDocument.eval (eval at isc__makeFunction (ISC_Core.js:2502:21), <anonymous>:3:127)

    InvoiceAdHocChargesTab.ts :
    Code:
    ///<reference path="tabs/dialog/AddNewInvoiceRecordPriceDialog.tsx"/>
    ///<reference path="../command/SendInvoiceReportExcelCommand.ts"/>
    ///<reference path="../command/UpdateInvoiceRecordPricesCommand.ts"/>
    ///<reference path="../ds/InvoiceRecordPriceDataSource.ts"/>
    
    namespace page.invoicing.tabs {
    
        import InvoiceRecordDataSource = page.invoicing.ds.InvoiceRecordDataSource;
        import Suspension = utils.coroutine.Suspension;
        import RecordHasChanges = crud.RecordHasChanges;
        import suppressibleFunction = utils.coroutine.suppressibleFunction;
        import InvoiceRecordPriceDataSource = page.invoicing.ds.InvoiceRecordPriceDataSource;
    
        import AddNewInvoiceRecordPriceDialog = page.invoicing.tabs.tabs.dialog.AddNewInvoiceRecordPriceDialog;
        import SendInvoiceReportExcelCommand = page.invoicing.command.SendInvoiceReportExcelCommand;
        import CreateAdditionalInvoiceRecordPriceCommand = page.invoicing.command.CreateAdditionalInvoiceRecordPriceCommand;
        import UpdateInvoiceRecordPricesCommand = page.invoicing.command.UpdateInvoiceRecordPricesCommand;
        import InvoiceAdHocChargeDataSource = page.invoicing.ds.InvoiceAdHocChargeDataSource;
    
    
        export class InvoiceAdHocChargesTab extends core.Tab<InvoiceAdHocChargesTabLayout> implements crud.RecordEditorTab<InvoiceAdHocChargeDataSource.Record> {
    
            readonly editorEventsRecords = crud.RecordEditorEvents.create<InvoiceAdHocChargeDataSource.Record>()
    
            // is filled on double click invoice row. Can't see why null is needed besides making TS not give error.
            // private invoiceRecord: InvoiceRecordDataSource.Record | null
            private invoiceRecord: InvoiceAdHocChargeDataSource.Record | null
    
            private invoiceRecordId: number
    
            editorEvents: crud.RecordEditorEvents<page.invoicing.ds.InvoiceAdHocChargeDataSource.Record>;
    
            constructor() {
                super(translation.invoicing.invoice_ad_hoc_charges);
                console.log('constructor');
            }
    
            protected createLayout(): page.invoicing.tabs.InvoiceAdHocChargesTabLayout {
                console.log('createLayout');
                return new InvoiceAdHocChargesTabLayout();
            }
    
            protected onInit(layout: page.invoicing.tabs.InvoiceAdHocChargesTabLayout) {
                console.log('onInit');
    
                this.tabEvents.onSelectedChanged.add(() => this.load())
    
                this.editorEventsRecords.editStarted.add(({record}) => {
                    // this is running on invoice line double click
                    console.log('edit started');
                    this.invoiceRecord = record
                    this.load()
                })
            }
    
            async edit(record: InvoiceRecordDataSource.Record, context?: undefined, suspension?: Suspension<RecordHasChanges>) {
                console.log('edit');
                Suspension(suspension).suspend(
                    {hasChanges: false},
                    () => this.editorEventsRecords.editStarted.fire({record, context})
                )
            }
    
            async save() {
    
            }
    
            private load() {
    
                console.log(this.selected, this.invoiceRecord);
                if (this.selected && this.invoiceRecord) {
                    console.log('gaunam recordus')
                    console.log(this.invoiceRecord);
    
                    this.layout._listGridRecords.fetchData({invoice: 1}) // todo get real invoice id
                }
            }
    
            async cancel(suspension?: Suspension<crud.RecordHasChanges>) {
            }
    
            validateTab(): Boolean {
                return true;
            }
    
        }
    }


    So it crashes on


    Code:
    this.layout._listGridRecords.fetchData({invoice: 1})
    Smart client developer console shows

    12:52:43.910:MUP3:WARN:Log:TypeError: Cannot read properties of undefined (reading 'fetchData')
    Stack from error.stack:
    InvoiceAdHocChargesTab.load(<no args: exited>) @ application.js:28321:54
    CallbackImpl.<anonymous>(<no args: exited>) @ application.js:28291:85
    null.<anonymous>(<no args: exited>) @ application.js:10087:77
    Function.forEach(<no args: exited>) @ underscore-min.js:5:2350
    CallbackImpl.fire(<no args: exited>) @ application.js:10087:15
    InvoiceAdHocChargesTab.__notifySelected(<no args: exited>) @ application.js:21128:51
    cons.tabSelected(<no args: exited>) on [TabSet ID:isc_TabSet_0] @ application.js:21214:37
    cons._tabSelected(<no args: exited>) on [TabSet ID:isc_TabSet_0] @ ISC_Containers.js:15189:18
    cons.buttonSelected(<no args: exited>) on [TabBar ID:isc_TabSet_0_tabBar] @ ISC_Containers.js:13350:36
    cons.setSelected(<no args: exited>) on [SimpleTabButton ID:isc_SimpleTabButton_2] @ ISC_Foundation.js:15606:59
    cons.select(<no args: exited>) on [SimpleTabButton ID:isc_SimpleTabButton_2] @ ISC_Foundation.js:3486:10
    cons.handleActivate(<no args: exited>) on [SimpleTabButton ID:isc_SimpleTabButton_2] @ ISC_Foundation.js:4681:14
    cons.handleClick(<no args: exited>) on [SimpleTabButton ID:isc_SimpleTabButton_2] @ ISC_Foundation.js:4721:17
    cons.invokeSuper(<no args: exited>) on [SimpleTabButton ID:isc_SimpleTabButton_2] @ ISC_Core.js:7187:44
    cons.Super(<no args: exited>) on [SimpleTabButton ID:isc_SimpleTabButton_2] @ ISC_Core.js:7005:21
    cons.handleClick(<no args: exited>) on [SimpleTabButton ID:isc_SimpleTabButton_2] @ ISC_Containers.js:543:21
    cons.bubbleEvent(<no args: exited>) on [Class EventHandler] @ ISC_Core.js:55037:44
    cons.handleClick(<no args: exited>) on [Class EventHandler] @ ISC_Core.js:52351:24
    cons._handleMouseUp(<no args: exited>) on [Class EventHandler] @ ISC_Core.js:52036:54
    cons.handleMouseUp(<no args: exited>) on [Class EventHandler] @ ISC_Core.js:51877:26
    cons.dispatch(handler=>[c]EventHandler.handleMouseUp(), event=>[object MouseEvent]) on [Class EventHandler] @ ISC_Core.js:56755:30
    HTMLDocument.eval(event=>[object MouseEvent]) @ [no file]:3:127


    How to fix that, what is wrong? Error tells "Cannot read properties of undefined" but it is not clear what is undefined.

    Please let me know if you neeed more info.

    ***************
    Update:

    Found that when running code, for some reason this object is undefined:


    Code:
    this.layout._listGridRecords
    But I have it defined in file, even PhpStorm when I ctrl+click finds it.

    InvoiceAdHocChargesTabLayout.tsx :
    Code:
    ///<reference path="../ds/InvoiceRecordPriceDataSource.ts"/>
    ///<reference path="tabs/InvoiceRecordPriceTab.ts"/>
    
    namespace page.invoicing.tabs {
    
        import InvoiceRecordDataSource = page.invoicing.ds.InvoiceRecordDataSource;
        import InvoiceAdHocChargeDataSource = page.invoicing.ds.InvoiceAdHocChargeDataSource;
    
        export class InvoiceAdHocChargesTabLayout implements core.Layout<isc.IVLayout> {
    
            readonly sc: isc.IVLayout;
    
            readonly _listGridRecords: isc.IListGrid<InvoiceAdHocChargeDataSource.Record>
    
            private readonly _events = {
    
            }
    
            get events() {
                return utils.Callback.publish(this._events)
            }
    
            constructor() {
    
            }
    
        }
    }
    So need help finding why it is undefined when running application.
    Last edited by dariusv; 9 Jun 2022, 04:11. Reason: Found more info

    #2
    Found solution:

    Need to assign this property in constructor:


    InvoiceAdHocChargesTabLayout.tsx:
    Code:
    ///<reference path="../ds/InvoiceRecordPriceDataSource.ts"/>
    ///<reference path="tabs/InvoiceRecordPriceTab.ts"/>
    
    namespace page.invoicing.tabs {
    
        import InvoiceRecordDataSource = page.invoicing.ds.InvoiceRecordDataSource;
        // import InvoiceRecordPriceTab = page.invoicing.tabs.tabs.InvoiceRecordPriceTab;
        // import DSID_InvoiceRecordDataSourceId = _cds.dsid.invoicing.DSID_InvoiceRecordDataSourceId;
        import InvoiceAdHocChargeDataSource = page.invoicing.ds.InvoiceAdHocChargeDataSource;
        // import InvoiceRecordPriceDataSource = page.invoicing.ds.InvoiceRecordPriceDataSource;
    
        export class InvoiceAdHocChargesTabLayout implements core.Layout<isc.IVLayout> {
    
            readonly sc: isc.IVLayout;
    
            // readonly _listGridRecords: isc.IListGrid<InvoiceRecordDataSource.Record>
            public _listGridRecords: isc.IListGrid<InvoiceAdHocChargeDataSource.Record>
    
            // readonly _listGridRecordPrices: isc.IListGrid<InvoiceRecordPriceDataSource.Record>
            //
            // readonly _buttonAddNew: isc.IButton
    
            // private _onAddClicked = utils.Callback()
            // readonly onAddClicked = this._onAddClicked.callback
    
            private readonly _events = {
                // onSendClicked: utils.Callback(),
                // onAddNewClicked: utils.Callback(),
                // onExportPdfClicked: utils.CallbackT<InvoiceRecordDataSource.Record>(),
                // onExportExcelClicked: utils.CallbackT<InvoiceRecordDataSource.Record>(),
                // onSendExcelClicked: utils.CallbackT<InvoiceRecordDataSource.Record>(),
                // updateInvoiceRecordPrices: utils.CallbackT<boolean>()
            }
    
            get events() {
                return utils.Callback.publish(this._events)
            }
    
            constructor() {
                this.sc =
                    <VLayout>
                        <HLayout height={30} membersMargin={5} layoutMargin={0}>
                            <LayoutSpacer/>
                            {/*<Button title={translation.invoicing.send}*/}
                            {/* click={() => this._events.onSendClicked.fire() }*/}
                            {/* autoFit/>*/}
                        </HLayout>
                        {this._listGridRecords =
                            <ListGrid dataSource={InvoiceRecordDataSource.sc()}
                                      useAllDataSourceFields={false}
                                      autoFetchData={false}
                                      selectionType="single"
                                      editEvent="doubleClick"
                                      showRecordComponents
                                      showRecordComponentsByCell
                                      // createRecordComponent={(record, colNum) => this._createListGridRecordComponent(record, colNum)}
                                      canEdit={core.AccessControl.instance.has(InvoiceRecordDataSource.get(), c.system.type.Permission.Update)}
                            >
                                <ListGridField name={"flightNo"}/>
                                <ListGridField name={"acType"}/>
                                <ListGridField name={"acReg"}/>
                                <ListGridField name={"route"}/>
                                <ListGridField name={"eventType"}/>
                                <ListGridField name={"scheduledDate"}/>
                                <ListGridField name={"#fullPrice"}/>
                                {/*<ListGridField name={"creditNote"}*/}
                                {/* change={(form, item, value, oldValue) => {*/}
                                {/* this._events.updateInvoiceRecordPrices.fire(value)*/}
                                {/* }}*/}
                                />
                                <ListGridField name={"#creditNoteType"}/>
                                <ListGridField name="#actions"
                                               canFilter={false}
                                               canSort={false}
                                               width={240}
                                               canEdit={false}
                                               title={translation.invoicing.actions}/>
                            </ListGrid>
                        }
                        {/*<HLayout height={30} membersMargin={5} layoutMargin={0}>*/}
                        {/* <LayoutSpacer/>*/}
                        {/* {this._buttonAddNew = <Button title={translation.button.add_new}*/}
                        {/* click={() => this._events.onAddNewClicked.fire()}*/}
                        {/* autoFit/>}*/}
                        {/*</HLayout>*/}
                        {/*{this._listGridRecordPrices =*/}
                        {/* <ListGrid dataSource={InvoiceRecordPriceDataSource.sc()}*/}
                        {/* useAllDataSourceFields={false}*/}
                        {/* autoFetchData={false}*/}
                        {/* selectionType="none"*/}
                        {/* canRemoveRecords*/}
                        {/* canEdit={true}*/}
                        {/* >*/}
                        {/* <ListGridField name={"name"}/>*/}
                        {/* <ListGridField name={"quantity"}/>*/}
                        {/* <ListGridField name={"price"}/>*/}
                        {/* <ListGridField name={"#currencyCode"}/>*/}
                        {/* <ListGridField name={"creditNote"}/>*/}
                        {/* <ListGridField name={"lastUpdatedTime"}/>*/}
                        {/* <ListGridField name={"lastUpdatedUser"}/>*/}
    
                        {/* </ListGrid>*/}
                        {/*}*/}
                    </VLayout>
            }
    
    
    
        }
    }
    See line
    Code:
    {this._listGridRecords =
    Last edited by dariusv; 9 Jun 2022, 04:46. Reason: Added exact line where to look

    Comment

    Working...
    X