Does anyone know what this error means and how can I fix this?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • macMonkey
    Junior Member
    • Nov 2024
    • 18

    Does anyone know what this error means and how can I fix this?

    Code:
    [Error] Unhandled Promise Rejection: Error: Collection has not been injected into views/record/list view.
    setup (espo-main.js:35:47299)
    _initialize (espo.js:17:210877)
    prepare (espo.js:17:226973)
    (anonymous function) (espo.js:17:226939)
    _getViewClass (espo.js:17:227297)
    create (espo.js:17:226841)
    (anonymous function) (espo.js:17:218606)
    Promise
    createView (espo.js:17:218448)
    setup (my-dialog.js:53)
    _initialize (espo.js:17:210877)
    prepare (espo.js:17:226973)
    (anonymous function) (espo.js:17:226939)
    (anonymous function) (espo.js:17:227381)
    forEach
    _executeLoadCallback (espo.js:6:202)
    _defineProceed (espo.js:6:752)
    (anonymous function) (espo.js:6:506)
    (anonymous function) (espo.js:6:1089)
    _load (espo.js:6:3163)
    (anonymous function) (espo.js:6:1012)
    forEach
    require (espo.js:6:997)
    define (espo.js:6:475)
    (anonymous function) (espo.js:6:7556)
    anonymous (my-dialog.js:3)
    _execute (espo.js:6)
    _handleResponseText (espo.js:6:5760)
    (anonymous function) (espo.js:6:5441)​
    This is the code that I'm using:
    Code:
    this.createView('record', 'views/record/list', {
    collection: this.wait(this.loadCollection()) ,
    type: 'listSmall',
    });​
    Code:
    async loadCollection() {
    this.collection = await this.getCollectionFactory().create('User');
    await this.collection.fetch();
    }​
    Last edited by macMonkey; 12-02-2024, 12:48 AM.
  • yuri
    Member
    • Mar 2014
    • 8440

    #2
    You need to load the collection collection asynchronously first. Then pass it to the list view. You can create a separate async method that will load the collection instance, and then creates the list view (asynchronously too). Then use this.wait(...) on this method in the setup method.
    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

    Comment

    Working...