Hi All,
I tried to follow this tutorial https://docs.espocrm.com/development/custom-buttons/
My problem is I am unable to navigate to next route.
The following code will not work. I have this error: Cannot read property 'navigate' of undefined. Which in fact means this.view does not exist
this.view.getRouter().navigate('#SalesOrder/create', {trigger: true});
Samely the following will not work
this.getRouter().navigate('#SalesOrder/create', {trigger: true});
Here is my full code.
define('custom:views/invoice/create-po-handler', [], function (Dep) {
return Dep.extend({
actionCreatePo: function (data, e) {
//Espo.Ajax.getRequest('Lead/' + this.view.model.id).then(function (response) {
console.log("actionCreatePo");
//});
},
initCreatePo: function () {
console.log("eer");
console.log(this);
console.log(this.view);
//this.view.getRouter().navigate('#SalesOrder/create', {trigger: true});
//this.controlButtonVisibility();
this.listenTo(
this.view.model, 'change:status', this.controlButtonVisibility.bind(this)
);
},
controlButtonVisibility: function () {
console.log("controlButtonVisibility");
/*if (~['Converted', 'Dead', 'Recycled'].indexOf(this.view.model.get('status'))) {
this.view.hideHeaderActionItem('someName');
} else {
this.view.showHeaderActionItem('someName');
}*/
},
});
});
Please can you tell me what am doing wrong here?
Thanks
I tried to follow this tutorial https://docs.espocrm.com/development/custom-buttons/
My problem is I am unable to navigate to next route.
The following code will not work. I have this error: Cannot read property 'navigate' of undefined. Which in fact means this.view does not exist
this.view.getRouter().navigate('#SalesOrder/create', {trigger: true});
Samely the following will not work
this.getRouter().navigate('#SalesOrder/create', {trigger: true});
Here is my full code.
define('custom:views/invoice/create-po-handler', [], function (Dep) {
return Dep.extend({
actionCreatePo: function (data, e) {
//Espo.Ajax.getRequest('Lead/' + this.view.model.id).then(function (response) {
console.log("actionCreatePo");
//});
},
initCreatePo: function () {
console.log("eer");
console.log(this);
console.log(this.view);
//this.view.getRouter().navigate('#SalesOrder/create', {trigger: true});
//this.controlButtonVisibility();
this.listenTo(
this.view.model, 'change:status', this.controlButtonVisibility.bind(this)
);
},
controlButtonVisibility: function () {
console.log("controlButtonVisibility");
/*if (~['Converted', 'Dead', 'Recycled'].indexOf(this.view.model.get('status'))) {
this.view.hideHeaderActionItem('someName');
} else {
this.view.showHeaderActionItem('someName');
}*/
},
});
});
Please can you tell me what am doing wrong here?
Thanks
Comment