Count attachments on a record

Has anyone managed to return the count of attachment records from a record. Having trouble validating whether a record has any attachments or not.

Like 0

Like

1 comments

Hello,

You can use the EntitySchemaQuery to get the number of attachments:

onEntityInitialized: function() {
				this.callParent(arguments);
				var contactId = this.get("Id");
				var esq = Ext.create("Terrasoft.EntitySchemaQuery", {rootSchemaName: "ContactFile"});
                esq.addColumn("Contact");
                    var filter = esq.createColumnFilterWithParameter(Terrasoft.ComparisonType.EQUAL, "Contact", contactId);
                    esq.filters.add("filter",filter);
                    esq.getEntityCollection(function (result) {
                        if (result.success) {
                        	window.alert("This record has " + result.collection.collection.length + " attachments");
                        }
                    }, this);
			},

 

Show all comments