Hello,
In freedomUI, i'm trying to override the EmailFormPage, i would like to filter the recipents list with the current account.
For now i have this non working filter :
{
request: "crt.HandleViewModelAttributeChangeRequest",
handler: async (request, next) => {
if(request.attributeName == "EmailComposer_RecipientsMailboxes")
{
const account = await request.$context.ActivityDS_Account_2vy71yu;
const filter = new sdk.FilterGroup();
await filter.addSchemaColumnFilterWithParameter(sdk.ComparisonType.Equal, "Account", account.value);
request.parameters.push({
type: "filter",
value: filter
});
}
return await next?.handle(request);
}
}
How should i fix this ?
Best regards
Patrice
Like
Hi Patrice,
The crt.HandleViewModelAttributeChangeRequest is not designed to have request parameters.
How it works:
1. The first time you open the recipient's dropdown or when you write text in the input, crt.RefreshEmailRecipientsRequest is triggered, which sends a request to the DB to get data (Email) from the VwRecepientEmail schema. Then crt.HandleViewModelAttributeChangeRequest is triggered for the EmailComposer_RecipientsMailboxes attribute with response data from crt.RefreshEmailRecipientsRequest in request.value.
2. crt.RefreshEmailRecipientsRequest has the following parameter: event: { query: null, recipientsLength: 0 }. The query is a text from the recipient's input. It is used to filter records from the VwRecepientEmail schema, checking whether the Email or ContactName columns contain the text specified in the query.
3. The VwRecipientEmail schema has a ContactId column, so in theory, if you have an account ID, you can get all the contacts associated with that account and extract the relevant data.
4. The problem is that crt.RefreshEmailRecipientsRequest is not designed to filter data by columns other than Email and ContactName. There are no parameters where you can specify a filter, like you tried using sdk.FilterGroup, and then request.parameters.push, etc.
So, there is no simple solution for what you are trying to achieve. I suggest using the sdk.Model class to retrieve and filter the data you need, and then replace the data coming from standard requests with the data you have.
Also, check out these articles, they may be useful:
https://academy.creatio.com/docs/8.x/dev/development-on-creatio-platform/front-end-development/freedom-ui/data-sources/crud-operations/references/model-class-js
https://customerfx.com/article/querying-data-using-filter-conditions-via-the-model-class-equivalent-to-enityschemaquery-in-a-creatio-freedom-ui-page/
Hello Eduard,
thanks for the detailled answer !
i will try to find my way with the Model class.
Best regards
Patrice
I managed to load the needed filtered collection.
Now i have a hard time setting the list in the page, the request.$context.EmailComposer_RecipientsMailboxes does not want to be updated.
Anybody know if this filtering may be available in future versions ?