Hi all,

I am trying to display a field from a related table on a page.

I have 2 objects: Account and Contact. I've added a new integer field to Account called UsrScore.

I'd like to display the UsrScore field on the Contact page (based on an attribute).

I'm fairly certain I want to use EntitySchemaQuery but I can't find the correct syntax. Any help would be appreciated.

Nb. I'm not using the Freedom UI. 

Like 0

Like

2 comments
Best reply

On the contact page, add an attribute to store the value from the account:

attributes: {
    "AccountScore": {
        dataValueType: Terrasoft.DataValueType.INTEGER
    }
}

Add onEntityInitialized in the methods where you'll retrieve the value from the account using the record's Account and store it in the attribute:

onEntityInitialized: function() {
    this.callParent(arguments);
 
    var account = this.get("Account");
 
    if (this.isAddMode() || !account) {
	    return;
    }
 
    var esq = Ext.create("Terrasoft.EntitySchemaQuery", {
        rootSchemaName: "Account"
    });
    esq.addColumn("UsrScore");
    esq.getEntity(account.value, function (result) {
        if (result.success) {
            this.set("AccountScore", result.entity.values.UsrScore);
        }
    }, this);
}

Lastly, you'll need to add an element to the diff bound to the attribute to display it on the page. Easily way to do this is to drag something not currently on the page, like ModifiedOn, then find it in the diff and change the name and bindTo (make sure you set it as disabled):

{
    "operation": "insert",
    "name": "AccountScoreValue",
    "values": {
        "bindTo": "AccountScore",
        "enabled": false,
        // etc ...
    },
    "parentName": "SomeWhere",
    "propertyName": "items",
    "index": 0
}

Ryan

On the contact page, add an attribute to store the value from the account:

attributes: {
    "AccountScore": {
        dataValueType: Terrasoft.DataValueType.INTEGER
    }
}

Add onEntityInitialized in the methods where you'll retrieve the value from the account using the record's Account and store it in the attribute:

onEntityInitialized: function() {
    this.callParent(arguments);
 
    var account = this.get("Account");
 
    if (this.isAddMode() || !account) {
	    return;
    }
 
    var esq = Ext.create("Terrasoft.EntitySchemaQuery", {
        rootSchemaName: "Account"
    });
    esq.addColumn("UsrScore");
    esq.getEntity(account.value, function (result) {
        if (result.success) {
            this.set("AccountScore", result.entity.values.UsrScore);
        }
    }, this);
}

Lastly, you'll need to add an element to the diff bound to the attribute to display it on the page. Easily way to do this is to drag something not currently on the page, like ModifiedOn, then find it in the diff and change the name and bindTo (make sure you set it as disabled):

{
    "operation": "insert",
    "name": "AccountScoreValue",
    "values": {
        "bindTo": "AccountScore",
        "enabled": false,
        // etc ...
    },
    "parentName": "SomeWhere",
    "propertyName": "items",
    "index": 0
}

Ryan

Worked perfectly. Thanks a lot.

Show all comments

Hello.

 

For now

request.$context.LookupPropName = undefined

clear the value, but not triggers any change events on page.

 

How can i clear lookup value on the page with triggering 

crt.HandleViewModelAttributeChangeRequest request?

Like 1

Like

1 comments

Hello,

It looks like the only possible solution for you would be to clear the value inside the business process.

Otherways you just don't trigger the handler.

Show all comments