Creatio development guide
PDF
This documentation is valid for Creatio version 7.10.0. We recommend using the newest version of Creatio documentation.

Getting query result

Glossary Item Box

The EntitySchemaQuery query result is a bpm'online property collection. Each instance of a collection is a string of a data set, returnable by query. You can get query results in the following ways:

  • Get a definite string of a data set by a primary key through calling the getEntity method (example 1).
  • Get entire resultant data set by calling getEntityCollection method (example 2).

Example 1. — Getting a definite data set string

// Get [Id] of card object.
var recordId = this.get("Id");
// Create Terrasoft.EntitySchemaQuery class instance with [Contact] root schema.
var esq = this.Ext.create("Terrasoft.EntitySchemaQuery", {
    rootSchemaName: "Contact"
});
// Add column with name of main contact of accounts that refers to given contact.
esq.addColumn("Account.PrimaryContact.Name", "PrimaryContactName");
// Get one record from selection on the basis of [Id] of card object and display it 
// in an info window.
esq.getEntity(recordId, function(result) {
    if (!result.success) {
        // error processing/logging, for example
        this.showInformationDialog("Data query error");
        return;
    }
    this.showInformationDialog(result.entity.get("PrimaryContactName"));
}, this);

Example 2. — Getting entire data set

var message = "";
// Create Terrasoft.EntitySchemaQuery class instance with [Contact] root schema.
var esq = Ext.create("Terrasoft.EntitySchemaQuery", {
    rootSchemaName: "Contact"
});
// Add column with account name that refers to given account.
esq.addColumn("Account.Name", "AccountName");
// Add column with name of main contact account that refers to given contact.
esq.addColumn("Account.PrimaryContact.Name", "PrimaryContactName");
// Get entire record colelction and display it in an infor window.
esq.getEntityCollection(function (result) {
    if (!result.success) {
        // error processing/logging, for example
        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);

Table 1. — Query result getting method

Method Description
getEntity(primaryColumnValue, callback, scope)

returns entity instance on set primary key [primaryColumnValue]. It calls [callback] function in [scope] context after data receipt.

primaryColumnValue String/Number Is a primary key value.
callback Function Is a function, called upon receipt of server response.
scope Object Context where [callback] function will be called.
getEntityCollection(callback, scope)

returns collection of entity instances that represent current query results. It calls [callback] function in [scope] context after data receipt.

callback Function Is a function that will be called upon receipt of server response.
scope Object Is a context where [callback] function will be called.

See Also

© bpm'online 2002-2017.

Did you find this information useful?

How can we improve it?