How can we create a mobile button that execute database queries?
Hi Community,
We've this situation where we need to execute a query to the database when we press the button that we created following this article https://academy.creatio.com/docs/developer/mobile_development/mobile_ap….
So far we manage to create the button itself and retrieve the record id when this button is pressed.
Ext.define("Terrasoft.controls.CustomRecordPanelItem", { extend: "Terrasoft.RecordPanelItem", requires: ["Terrasoft.EntitySchemaQuery"], xtype: "cftestrecordpanelitem", config: { items: [ { xtype: "container", layout: "hbox", items: [ { xtype: "button", cls: 'btn', id: "clickMeButton", text: '<div style="color: white">TERMINAR</div>', flex: 5, }, ] } ] }, initialize: function() { var clickMeButton = Ext.getCmp("clickMeButton"); clickMeButton.element.on("tap", this.onClickMeButtonClick, this); }, onClickMeButtonClick: function() { var record = this.getRecord(); var servicoId= record.data.imdServico.data.Id; var activitycategoryId = '82e0f151-a00a-46c5-8916-b87992266de6'; var esq = this.Ext.create("Terrasoft.EntitySchemaQuery", { rootSchemaName: "Activity" }); esq.addColumn("imdServicos.Id", "ServicoId"); esq.addColumn("ActivityCategory.Id", "TipoCheckListId"); var esqFirstFilter = esq.createColumnFilterWithParameter(Terrasoft.ComparisonType.EQUAL, "imdServicos.Id", servicoId); var esqSecondFilter = esq.createColumnFilterWithParameter(Terrasoft.ComparisonType.EQUAL, "ActivityCategory.Id", activitycategoryId); esq.filters.logicalOperation = Terrasoft.LogicalOperatorType.AND; esq.filters.add("esqFirstFilter", esqFirstFilter); esq.filters.add("esqSecondFilter", esqSecondFilter); esq.getEntityCollection(function (result) { if (result.success) { window.console.log(result); /*result.collection.each(function (item) { });*/ } }, this); Terrasoft.MessageBox.showMessage(record); } });
We are having problems trying to execute the Ext.create("Terrasoft.EntitySchemaQuery") because we think that some dependencies are missing.
Any idea on how to solve this problem?
Thanks in Advance.
Best Regards,
Pedro Pinheiro
Like
Hi Pedro,
Can you send the debug result using the mobile application emulator? What is the error?
Best regards,
Oscar
Hi Oscar Dylan,
Thank you for your response. The following image shows the error that we are getting when pressing the button.
var esq = this.Ext.create("Terrasoft.EntitySchemaQuery", { rootSchemaName: "Activity" });
We think that the error might be related to the lack of dependencies.
Best Regards,
Pedro Pinheiro
Hello Pedro. Did you manage to get the result of the queries?