Is there a way to get the invoice internal ID into...
# suitecommerce
c
Is there a way to get the invoice internal ID into a custom extension's service controller? I can see the model.internalid is available on the TPL in the theme, it's not clear how I can reuse this value in a custom extension though.
s
You would do something like
container.getLayout().getCurrentView().model
And then pull the ID from that
Stuff like
this.application
is also a substitute for
container
sometimes. It all depends on the context
c
I'll try, thanks.
Still wrestling with this.
This is undefined
Copy code
mountToApp: function mountToApp(container) {
    var layout = container.getLayout().getCurrentView()
    console.log(layout);
}
s
Yeah at that point in the extension timeline, there is no layout
The point is that when you initialise some part of the extension (eg the main view) then the parent view (the layout view) will be ready, and you can access those properties
c
Probably needs to be inside here then
Copy code
layout.addChildView('Invoice.PaymentLink', function () {
s
You could pass the application object to that
c
Trying this now (just takes a while to activate)
Copy code
mountToApp: function mountToApp(container) {
    var layout = container.getComponent('Layout');
    console.log('PaymentLinkOverride: layout', layout);

    layout.addChildView('Invoice.PaymentLink', function () {
       console.log('this', this);
       var model = this && this.model;
       console.log('model', model);
s
Well you should probably pass
container
c
I did this
Copy code
return {
    mountToApp: function mountToApp(container) {
       var layout = container.getComponent('Layout');
       console.log('PaymentLinkOverride: layout', layout);

       layout.addChildView('Invoice.PaymentLink', function () {
          return new LinkView({
             container: container
          });
       });
    }
}
Then this in the View
Copy code
initialize: function initialize(options) {
    var self = this;

    console.log('this', this);
    console.log('options', options);
I think
this
has the data I am looking for.
It looks like
this.placeholderData
is not available even though I can see it in the chrome console I really didn't want to have to scrape this ID out of the URL.