Get data from a Drawer

If I have something like this in my record.js, the module is Notes

app.drawer.open({
     layout: 'create',
     context: {
          create: true,
          module: linkModule,
          recParentModel: parentModel,
          model: prefill,
          recLink: link,
          recContext: this.context,
          recView: this.view
                              }
     }, _.bind(function (model) {
          //get data from model here
        }

is there a way to get the savd note ID and DESCRIPTION from 'model'?  I have tried everything I know and I cant seem to get back to the record that was created from the opened drawer.

  • Hi Kenneth Brill,

    I tried your code and it worked for me. Hope, you are using 'this' with the _.bind function like:

    _.bind(function (model) {
          //get data from model here
          console.log('my notes model: ',model);

    }, this));

    You can even use it without the bind function.

    Also, please try printing console.log(model) and verify the value you are getting in model variable.

    Regards.

  • It does return the model but I cant get any data for example none of these return anything

    }, _.bind(function (model) {
         console.log(model.get('id'));
         console.log(model.get('description'));
         console.log(model.id);
         console.log(model.description);
         console.log(this.model.get('id'));
         console.log(this.model.get('description'));
    }, this));
  • Hi Kenneth Brill,

    Would you please console.log(model) and check its contents. Also, try without the _.bind function and see if that helps.

  • Not sure what you mean "without the bind function"

    console.log(model) gives me

    {}
    _changing: false
    _events: Object {  }
    _fetchCalled: false
    _pending: false
    _previousAttributes: Object { create: true, module: "Notes", recParentModel: "Cases",}
    attributes: Object { create: true, module: "Notes", recParentModel: "Cases",}
    changed: Object {  }
    children: Array(11) [ {}, {}, {},]
    cid: "c4701"
    id: "c4701"
    lastSaveAction: null
    parent: Object { cid: "c4", _changing: false, _pending: false,}
    <prototype>: Object { initialize: initialize(), clear: clear(), resetLoadFlag: resetLoadFlag(),}
    components_01edb5a18fd2135ec72fb29083f1cb9b.js:5032:7
  • I figured it out

    app.drawer.open(
    {
         layout: 'create',
         context: {
              create: true,
              module: linkModule,
              recParentModel: parentModel,
                 model: prefill,
              recLink: link,
              recContext: this.context,
              recView: this.view
         }
    }, _.bind(function (context, newModel) {
         console.log(newModel.get('id'));
         console.log(newModel.get('description'));
    }}, this);

    I did that by hand so I might not have the right number of braces but you get the jist.