How would I go about this?
I need to filter a lookup (aka dropdown). There is a CustomerFX example here of filtering the Case form page Contact dropdown to only those contacts of the case's account (i.e., contact's account == case's account).
However I need to filter a dropdown to only show records that are listed in a column in a detail on the same form page (i.e., dropdown item account exists in a subquery of all the accounts listed in a detail on the same form page) .
Thanks in advance,
Like
Perform the ESQ call like (don't forget to add @creatio-devkit/common as a dependency):
const accountModel = await sdk.Model.create("Contact"); const filters = new sdk.FilterGroup(); let currentAccountId = await request.$context.Id; await filters.addSchemaColumnFilterWithParameter(sdk.ComparisonType.Equal, "Account", currentAccountId); const result = await accountModel.load({ attributes: ["Id", "Name"], parameters: [{ type: sdk.ModelParameterType.Filter, value: filters }] }); console.log(result);
You will receive an array of objects as a result of this query execution. Filtration in
await filters.addSchemaColumnFilterWithParameter(sdk.ComparisonType.Equal, "Account", currentAccountId);
should be the same as in your detail.
After that you can parse the received object, get the list of IDs and use it in your dropdown filtration.