Overriding "Add New" Button in Freedom UI Lookup to Pass Default Values

Hi Community,

I am working in Freedom UI (8.3) and I need to override the behavior of the "Add New" button inside a lookup/dropdown field. Specifically, I want to pass parameters (default values) from the current page to the new record form that opens when a user clicks the "Add" button.

Button Image

I have tried overriding the handler crt.CreateRecordFromLookupRequest, but the values are not populating on the target page.

  • Is request.defaultValues the correct property to use for CreateRecordFromLookupRequest
  • Note: Please assume all attribute names used in the code block below have been verified as correct; I have updated them to generic names for the purpose of this example.

    {
        request: "crt.CreateRecordFromLookupRequest",
        handler: async (request, next) => {
  
            if (request.attributeName === 'PDS_Facility') {
                
                request.defaultValues = request.defaultValues || [];

                const accountLookup = await request.$context.PDS_Account;

                if (accountLookup && accountLookup.value) {
                    request.defaultValues.push({
                        name: "Account",
                        value: accountLookup.value
                    });
                }
            }
            return next?.handle(request);
        }
    }

Like 1

Like

2 comments

Hello Prabhath Surya,

crt.CreateRecordFromLookupRequest does not support page parameters. As a workaround, you can implement this using the browser’s native BroadcastChannel API to pass values.

Please refer to the following post for the example:
https://community.creatio.com/questions/open-custom-freedom-ui-page-custom-button-opportunity-edit-page-and-pass-opportunity

Eduard Dovydovskyi,

While the BroadcastChannel API is a good workaround for CreateRecordFromLookupRequest limitations, wouldn't it be more efficient to use crt.CreateRecordRequest if we are already using a custom button? Since crt.CreateRecordRequest natively supports the defaultValues array, we can pass parameters directly into the new page context without needing to manage browser-level messaging.

Show all comments