Lookup not displayed on form

I’m trying to make a lookup that contains fields from 3 different tables. l1

I created a temp table( InMemory type), put it as a datasource to my form.
Here is a code for lookup that i put in form datasource level code.

public void lookup(FormControl _formControl, str _filterStr)
    {
        TempTable tmp;
        switch (HeaderTable.ProductTypes)
        {
            case ProductTypes::Product:

                tmp.clear();
                tmp.initValue();
                tmp.ChangingField = "SearchName";
                tmp.insert();
                
                tmp.clear();
                tmp.initValue();
                tmp.ChangingField = "RetailColorGroupId";
                tmp.insert();
               
                tmp.clear();
                tmp.initValue();
                tmp.ChangingField = "RetailSizeGroupId";
                tmp.insert();
                
                tmp.clear();
                tmp.initValue();
                tmp.ChangingField = "RetailStyleGroupId";
                tmp.insert();
                break;

            case ProductTypes::Variant:

                tmp.clear();
                tmp.initValue();
                tmp.ChangingField = "SearchName";
                tmp.insert();
                

                tmp.clear();
                tmp.initValue();
                tmp.ChangingField = "RetailTotalWeight";
                tmp.insert();
                break;
        }
        
        SysTableLookup sysTableLookup = SysTableLookup::newParameters(tablenum(TempTable), _formControl);
        Query query = new Query();
        QueryBuildDataSource queryBuildDataSource;
                
        queryBuildDataSource = query.addDataSource(tablenum(TempTable));

        sysTableLookup.addLookupfield(fieldnum(TempTable, ChangingField), true);

        sysTableLookup.parmQuery(query);
                
        sysTableLookup.parmTmpBuffer(tmp);
        sysTableLookup.performFormLookup();
    }

The lookup doesn’t work.
Is there anything else that is needed to be done?

First of all, what exactly do you mean by “it doesn’t work”? What happens?
Then consider if you really want to use a temporary table. I wouldn’t. If I want to return fields from multiple tables, I would use either SysMultiTableLookup or a view. There may be reasons to use a temporary table, but it’s not needed just to return data from several tables.
If you want to use your current approach anyway, then please debug your code. Maybe no line is inserted because headerTable.ProductTypes doesn’t contain the right value.
By the way, which version of AX it is about? (Please attach a version tag, e.g. AX 2012 or D365FO, when creating a new thread.)