Hi All
I have a function that is triggered when Account is changed on Lead.
I use the common code for getting query results:
var recordId = this.get("Id");
var esq = this.Ext.create("Terrasoft.EntitySchemaQuery", { rootSchemaName: "Lead"
and the code to get my query resluts:
esq.getEntity(recordId, function(result) {}
It works fine but not before save.
Before save I bbelieve I don't have the recordId yet and this is why I can't get query results.
Any ideas?
Maybe there is a way to use the Id of the account that was chosen in the lookup and use it ?
Thanks
Like
Dear Oren,
The schema responsible for account in lead section is "LeadAccountProfileSchema". It inherits from "BaseProfileSchema". There is method onLookupResult(), which contains info about selected new account.
You can override this method in the replacing "LeadAccountProfileSchema" module. You can retrieve the new account id like this: selectedRows.getByIndex(0).Id.
Hope you find it helpful!
Regards,
Anastasia
Anastasia Botezat,
Thanks Anastasia
The method "onLookupResult" indid works when new account is selected.
Can you be more specific about getting the account Id ?
If for example I want to query information from the account table, should I use it like this?:
var recordId = selectedRows.getByIndex(0).Id;
var esq = this.Ext.create("Terrasoft.EntitySchemaQuery", {
rootSchemaName: "Account"
});
esq.getEntity(recordId, function(result){}
Dear Oren,
You can create a custom method, which will contain your ESQ to Account. In the onLookupResult() method, where you retrieve the id you can call custom function with ESQ and pass the retrieved Id as an argument to that method and then use it in the function to set ESQ filter.
onLookupResult: function() { //basic logic var accId = selectedRows.getByIndex(0).Id; this.customESQAccount(accId); }
Regards,
Anastasia
Thanks again Anastasia
There is a problem with your code.
Code Validation says:
selectedRows is not defined
I need to get the Account Id but please note that all is happening before save so I don't have the Lead record Id yet.
How can I get the selected Account Id ?