Question

Get field from connected to

On the EmailPageV2 I am trying to get an account using this.get("Account"), but it always returns undefined. I think it is because it uses the connected to detail. How can I get this account from the connected to detail? 

 

 

Like 0

Like

3 comments

Hi Tyler,

I can get the account on EmailPageV2 by using this.get("Account"). What is the method you're using this in? (I just tested in onEntityInitialized and was able to retrieve it fine).

The connected to detail is just a visual representation. Since the email is an Activity as it's entity type, the Account column does exist on the Activity, so you should be able to get it the usual way.

Ryan

Ryan Farley,

 

This is my code. It seems like it would work. Maybe I am missing something small, or my instance is bugged. 

			onEntityInitialized: function() {
				this.callParent(arguments);
 
				this.setAccountContactIds();
 
			},
			setAccountContactIds: function() {
				const contactIdArr = [];
				window.console.log(this.get("Accounts"));
 
				const accountId = this.get("Account").value;
 
 
				var esq = Ext.create("Terrasoft.EntitySchemaQuery", {
				    rootSchemaName: "Contact"
				});
				esq.addColumn("Id");
				esq.addColumn("Account");
				esq.filters.logicalOperation = this.Terrasoft.LogicalOperatorType.OR;
				// Creation of the first filter instance.
				var esqIdFilter = esq.createColumnFilterWithParameter(Terrasoft.ComparisonType.EQUAL, "Account", accountId);
				// Filters will be updated by OR logical operator in query filters collection. 
				var ourAccountFilter = esq.createColumnFilterWithParameter(Terrasoft.ComparisonType.EQUAL, "Account", Terrasoft.SysValue.CURRENT_USER_ACCOUNT.value);
 
				// Adding created filters to collection. 
				esq.filters.add("esqIdFilter", esqIdFilter);
				esq.filters.add("ourAccountFilter", ourAccountFilter);
				// This collection will include objects, i.e. query results, filtered by two filters.
				esq.getEntityCollection(function (result) {
				    if (result.success) {
				        result.collection.each(function (item) {
				        	contactIdArr.push(item.values.Id);
				        });
				        this.set("AccountContactIds", contactIdArr);
				    }
				}, this);
			},

That console.log prints undefined.

In the code above, the console.log is outputting this.get("Accounts") <-plural, not "Account" <- singular. Could it be that is why you're seeing undefined in the console? Have to tried debugging in dev tools to see the value of accountId? Does it show correct or also undefined?

Ryan

Show all comments