Question

Count of address

Hello all,

 

I would like to count all of the address by type in the Address detail of an account and set it to a field. I know how to set the field, but I am unable to see how to get to the address object from the account page.

Thank you

 

Like 0

Like

1 comments
Best reply

You'd have to do an ESQ from the Account to read AccountAddress where the Account = the current Account Id. Like this:

var esq = this.Ext.create("Terrasoft.EntitySchemaQuery", {
    rootSchemaName: "AccountAddress"
});
esq.addAggregationSchemaColumn("Id", Terrasoft.AggregationType.COUNT, "AddressCount");
esq.filters.add(Terrasoft.createColumnFilterWithParameter(Terrasoft.ComparisonType.EQUAL, "Account", this.get("Id"));
// also add type filter as needed
esq.getEntityCollection(function(result) {
    console.log("Total addresses", result.collection.first().get("AddressCount"));
}, this);

Ryan

You'd have to do an ESQ from the Account to read AccountAddress where the Account = the current Account Id. Like this:

var esq = this.Ext.create("Terrasoft.EntitySchemaQuery", {
    rootSchemaName: "AccountAddress"
});
esq.addAggregationSchemaColumn("Id", Terrasoft.AggregationType.COUNT, "AddressCount");
esq.filters.add(Terrasoft.createColumnFilterWithParameter(Terrasoft.ComparisonType.EQUAL, "Account", this.get("Id"));
// also add type filter as needed
esq.getEntityCollection(function(result) {
    console.log("Total addresses", result.collection.first().get("AddressCount"));
}, this);

Ryan

Show all comments