Retrieve the query results
Level: intermediate
note
The functionality is relevant to Classic UI.
Dataset string by the specified primary key
Example
Retrieve a particular dataset string by the specified primary key
Example that retrieves a particular dataset string
/* Retrieve the ID of the mini page object. */
var recordId = this.get("Id");
/* Create an instance of the Terrasoft.EntitySchemaQuery class with the Contact root schema. */
var esq = this.Ext.create("Terrasoft.EntitySchemaQuery", {
rootSchemaName: "Contact"
});
/* Add a column that contains the name of the account’s primary contact. */
esq.addColumn("Account.PrimaryContact.Name", "PrimaryContactName");
/* Retrieve one record from the selection by the ID of the mini page object. Display the record in the information box. */
esq.getEntity(recordId, function(result) {
if (!result.success) {
// For example, error processing/logging.
this.showInformationDialog("Data query error");
return;
}
this.showInformationDialog(result.entity.get("PrimaryContactName"));
}, this);
note
If you retrieve lookup columns, the this.get()
returns the object, not ID of the record in the database. To retrieve the ID, use the value
property. For example, this.get('Account').value
.
Resulting dataset
Example
Retrieve the entire resulting dataset.
Example that retrieves the entire dataset
var message = "";
/* Create an instance of the Terrasoft.EntitySchemaQuery class with the Contact root schema. */
var esq = Ext.create("Terrasoft.EntitySchemaQuery", {
rootSchemaName: "Contact"
});
/* Add a column that contains the name of the account connected to the contact. */
esq.addColumn("Account.Name", "AccountName");
/* Add a column that contains the name of the account’s primary contact. */
esq.addColumn("Account.PrimaryContact.Name", "PrimaryContactName");
/* Retrieve the entire record collection and display it in the information box. */
esq.getEntityCollection(function (result) {
if (!result.success) {
/* For example, error processing/logging. */
this.showInformationDialog("Data query error");
return;
}
result.collection.each(function (item) {
message += "Account name: " + item.get("AccountName") +
" - primary contact name: " + item.get("PrimaryContactName") + "\n";
});
this.showInformationDialog(message);
}, this);