Hi Team,
I'm trying to extend a base function in my custom controller. And the code is loading once I open the page but is not triggering the function. Is this the correct way? What I'm doing wrong in this case?

So I have the custom controller created in this way:
Ext.define("Terrasoft.configuration.controller.SMAgilizExpenseManagementGridPage", {
extend: "Terrasoft.controller.BaseGridPage",
statics: {
Model: AgilizExpenseManagement
},
config: {
refs: {
view: "#AgilizExpenseManagementGridPage"
}
},
/**
* @inheritdoc
* @protected
* @overridden
*/
getChangeModeOperations: function() {
var detailConfig = this.getDetailConfig();
if (detailConfig) {
var parentRecord = detailConfig.parentRecord;
if (parentRecord.get("IsNonActualEmail") === false) {
return {
canCreate: false,
canUpdate: false,
canDelete: false
};
}
}
return this.callParent(arguments);
},
initializeQueryConfig: function() {
this.callParent(arguments);
var gridQueryConfig = this.getQueryConfig();
gridQueryConfig.addColumns(this.startDateColumnName, this.endDateColumnName);
if (Terrasoft.FeatureUtils.isHybridMode()) {
gridQueryConfig.setIsBatch(false);
}
},
});

And is added in the MobileApplicationManifestDefaultWorkplace as well:
Like
Hi Oscar, I solve it with this code. We change the extend for override. Of course this override for the entire app but works for me :)
Ext.define("Terrasoft.controller.AgilizExpenseManagement", {
override: "Terrasoft.controller.BaseModelPage",
statics: {
Model: AgilizExpenseManagement
},
/**
* @inheritdoc
* @protected
* @overridden
*/
getChangeModeOperations: function() {
var detailConfig = this.getDetailConfig();
if (detailConfig && detailConfig.parentRecord.data.AgilizExpenseStatus.id) {
var parentRecord = detailConfig.parentRecord;
if ( parentRecord.data.AgilizExpenseStatus.id && parentRecord.data.AgilizExpenseStatus.id !== "f50b9fd6-21ed-47ff-8450-e7f5f9c82c5f") {
return {
canCreate: false,
canUpdate: false,
canDelete: false
};
}
}
return this.callParent(arguments);
}
});
Hi Federico,
This method is a part of the BaseModelPage controller:

Try extending the Terrasoft.controller.BaseModelPage. Also please check if the extended module is added to the CustomSchemas sync option in the manifest.
Best regards,
Oscar
Hi Oscar Dylan,
I try to add the BaseModelPage in extended but still is calling the base one. The schema is loading in the debbuger but is not trigged the function. I added in the customschemas as well.
Something is missing in my code?
Ext.define("Terrasoft.controller.SMAgilizExpenseManagement", {
extend: "Terrasoft.controller.BaseModelPage",
statics: {
Model: AgilizExpenseManagement
},
/**
* @inheritdoc
* @protected
* @overridden
*/
getChangeModeOperations: function() {
window.alert("Test");
var detailConfig = this.getDetailConfig();
if (detailConfig) {
var parentRecord = detailConfig.parentRecord;
if (parentRecord.get("IsNonActualEmail") === false) {
return {
canCreate: false,
canUpdate: false,
canDelete: false
};
}
}
return this.callParent(arguments);
}
});
I tried to extend the controller in many ways but looks is not working. Somebody have a example to share?
Federico Buffa ...,
Hi,
I am studying the base AccountPreviewPage code to give you an example of the controller extension. Please give me a couple of days and I will return to you with an update.
Meanwhile if someone has an example - it would also help us much!
Best regards,
Oscar
Hi Oscar, I solve it with this code. We change the extend for override. Of course this override for the entire app but works for me :)
Ext.define("Terrasoft.controller.AgilizExpenseManagement", {
override: "Terrasoft.controller.BaseModelPage",
statics: {
Model: AgilizExpenseManagement
},
/**
* @inheritdoc
* @protected
* @overridden
*/
getChangeModeOperations: function() {
var detailConfig = this.getDetailConfig();
if (detailConfig && detailConfig.parentRecord.data.AgilizExpenseStatus.id) {
var parentRecord = detailConfig.parentRecord;
if ( parentRecord.data.AgilizExpenseStatus.id && parentRecord.data.AgilizExpenseStatus.id !== "f50b9fd6-21ed-47ff-8450-e7f5f9c82c5f") {
return {
canCreate: false,
canUpdate: false,
canDelete: false
};
}
}
return this.callParent(arguments);
}
});
Looks the function is working for the fields but no for the button edit. I can't find the logic for that.
this solutions works to hide the edit button if the permission canUpdate is false
Ext.define("Terrasoft.controller.AgilizExpenseManagementPreviewPage", {
override: "Terrasoft.controller.BasePreviewPage",
initNavigationButtons: function() {
this.callParent(arguments);
let view = this.getView();
if (this.getChangeModeOperations().canUpdate && view.getEditButton()) {
let editButton = view.showEditButton(true);
editButton.on("tap", this.onEditButtonTap, this);
} else {
view.showEditButton(false);
}
}
});