Filtering Primary Contact Field

Hi, 

 

When you click the 'Search' button when establishing a 'Primary Contact' for an account. Can i filter the lookup to only show contacts that belong to the account record you are in?

 

Currently it returns a list of every contact we have in CRM.

 

I tried to do it via a business rule with no avail.

 

Thanks

Like 0

Like

4 comments

Hello Tom, 

 

It's not possible to implement your business task with a help of basic system tools, the additional development will be needed. 

The same question has been already discussed in a separate post on our Community, please refer to it in case you'd like to proceed with implementation by code. 



Best regards,

Anastasiia

Hi Anastasiia,

Is there a way to do this in Freedom UI through code or filters of some kind?

Vincent Nguyen hello,

  1. Add @creatio-devkit/common usage into Accounts_FormPage

define("Accounts_FormPage", /**SCHEMA_DEPS*/["@creatio-devkit/common"]/**SCHEMA_DEPS*/, function/**SCHEMA_ARGS*/(sdk)/**SCHEMA_ARGS*/ {

2. Add the following handler to the page

{
                request: "crt.LoadDataRequest",
                handler: async (request, next) => {
                    const currentAccountId = await request.$context.Id;
                    const contactAttr = "PrimaryContact";

                    if (request.dataSourceName === `${contactAttr}_List_DS`) {
                        const filter = new sdk.FilterGroup();
                        await filter.addSchemaColumnFilterWithParameter(sdk.ComparisonType.Equal, "Account", currentAccountId);
                        request.parameters.push({ type: "filter", value: filter.toJson() });
                    }

                    return await next?.handle(request);
                }
            }

3. Refresh the page and check the result.

Hi Oleg is the handler compatible for 8.2.0 or the latest version. Currently I'm on 8.2.0 and its not working. I also had a question about the request.parameters.push({ type: "filter", value: filter.toJson() }); what does it do?

Show all comments