Question

How to trigger event on lookup field change?

Hi community

I made a trigger on a lookup field using this attribute:

"UsrAmazonWarehouseAddress":{
    "dependencies": [
        {
            "columns": ["UsrAmazonWarehouseAddress"],
            "methodName": "onAmazonWharehouseChange"
        }
    ]
},

The thing is that this trigger is fired only if the user choose value by cliking it on the popup window. If the user uses only the keyboard without openning the lookup window, the trigger is not fired.

Any ideas on how to catch the evet of changing the lookup ?

Thanks

Like 0

Like

2 comments

I've just created the dependency specified below and it works no matter how it was triggered. Please test the code on your side and check the difference. 

define("AccountPageV2", [], function() {
	return {
		entitySchemaName: "Account",
		attributes: {
			"Owner": {
				"dependencies": [
					{
						"columns": ["Owner"],
						"methodName": "onOwnerChanged"
					}
				]
			}
		},
		modules: /**SCHEMA_MODULES*/{}/**SCHEMA_MODULES*/,
		details: /**SCHEMA_DETAILS*/{}/**SCHEMA_DETAILS*/,
		businessRules: /**SCHEMA_BUSINESS_RULES*/{}/**SCHEMA_BUSINESS_RULES*/,
		methods: {
			onOwnerChanged: function(){
				window.alert("onOwnerChanged");
			}
		},
		dataModels: /**SCHEMA_DATA_MODELS*/{}/**SCHEMA_DATA_MODELS*/,
		diff: /**SCHEMA_DIFF*/[]/**SCHEMA_DIFF*/
	};
});

 

Thanks Eugene

You are rihgt. I checked and the trigger is fired.

I checked and and found the problem:

This is how I got the recordId.

var recordId = this.get("UsrAllAddresses").Id;

When choosing with the popup window, recordId has the ID value

When choosing without the popup window, recordId is undefined.

The solution I found goes like this:

var record = this.get("UsrAllAddresses");

 var recordId=record.value;

Best regards,

Show all comments