web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

'Must be called with Common table buffer passed' after adding datasource and grid in form extension

(0) ShareShare
ReportReport
Posted on by 339
Hey all,
 
I created a new table with relations to the ProjInvoiceTable and LogisticsElectronicAddress:
 
I extended the form ProjInvoiceTable with a tab, containing a grid:
 
The Tab, grid, actionpane and actionpanetabs all have the new table I created and added as datasource (delayed linktype join to ProjInvoiceTable) as datasource property
 
I can now perfectly add records to the table via the form, that is working as intended.
 
However, once I click the D365 automatically created hyperlinks that get created I receive the error: 'Must be called with Common table buffer passed':
 
A good thing to note is that I did add a form eventhandler to make sure that the dropdown only shows contactinfo's of type email that correspond to the customers mentioned as the projectInvoices' projectfundingsource:
public final class FM_ProjInvoiceTable_EventHandlers
{
    /// <summary>
    /// Handles the OnLookup event for FM_LogisticsElectronicAddressLocator control
    /// </summary>
    /// <param name="sender">The form control</param>
    /// <param name="e">Event arguments</param>
    [FormControlEventHandler(formControlStr(ProjInvoiceTable, FM_LogisticsElectronicAddressLocator), FormControlEventType::Lookup)]
    public static void FM_LogisticsElectronicAddressLocator_OnLookup(FormControl sender, FormControlEventArgs e)
    {
        Query                   query;
        QueryBuildDataSource    qbds;
        QueryBuildDataSource    qbdsLogisticsLocation;
        QueryBuildDataSource    qbdsDirPartyLocation;
        QueryBuildDataSource    qbdsLogisticsLocationRole;
        QueryBuildDataSource    qbdsCustTable;
        QueryBuildDataSource    qbdsProjFundingSource;
        SysTableLookup          sysTableLookup;
        FormStringControl       ctrl = sender as FormStringControl;
        FormRun                 formRun = sender.formRun();
        FormDataSource          fdsProjInvoiceTable = formRun.dataSource(formDataSourceStr(ProjInvoiceTable, ProjInvoiceTable));
        ProjInvoiceTable        projInvoiceTable = fdsProjInvoiceTable.cursor();

        // If no project invoice, allow default lookup
        if (!projInvoiceTable.ProjInvoiceProjId)
        {
            return;
        }
        
        // Create the base query for LogisticsElectronicAddress
        query = new Query();
        qbds = query.addDataSource(tableNum(LogisticsElectronicAddress));
        
        // Filter by Type = 2 (Email address)
        qbds.addRange(fieldNum(LogisticsElectronicAddress, Type)).value(queryValue(LogisticsElectronicAddressMethodType::Email));
        
        // Join to LogisticsLocation to connect with DirPartyLocation
        qbdsLogisticsLocation = qbds.addDataSource(tableNum(LogisticsLocation));
        qbdsLogisticsLocation.addLink(fieldNum(LogisticsElectronicAddress, Location), fieldNum(LogisticsLocation, RecId));
        qbdsLogisticsLocation.joinMode(JoinMode::InnerJoin);
        
        // Join to DirPartyLocation to link location with party
        qbdsDirPartyLocation = qbdsLogisticsLocation.addDataSource(tableNum(DirPartyLocation));
        qbdsDirPartyLocation.addLink(fieldNum(LogisticsLocation, RecId), fieldNum(DirPartyLocation, Location));
        qbdsDirPartyLocation.joinMode(JoinMode::InnerJoin);
        
        // Join to LogisticsLocationRole to filter by FM_DefaultOnProjectContract
        qbdsLogisticsLocationRole = qbds.addDataSource(tableNum(LogisticsLocationRole));
        qbdsLogisticsLocationRole.addLink(fieldNum(LogisticsElectronicAddress, ElectronicAddressRoles), fieldNum(LogisticsLocationRole, Name));
        qbdsLogisticsLocationRole.joinMode(JoinMode::InnerJoin);
        
        // Filter by FM_DefaultOnProjectContract = true
        qbdsLogisticsLocationRole.addRange(fieldNum(LogisticsLocationRole, FM_DefaultOnProjectContract)).value(queryValue(NoYes::Yes));
        
        // Join to CustTable to get customer party
        qbdsCustTable = qbdsDirPartyLocation.addDataSource(tableNum(CustTable));
        qbdsCustTable.addLink(fieldNum(DirPartyLocation, Party), fieldNum(CustTable, Party));
        qbdsCustTable.joinMode(JoinMode::InnerJoin);
        
        // Join to ProjFundingSource to filter by project funding sources
        qbdsProjFundingSource = qbdsCustTable.addDataSource(tableNum(ProjFundingSource));
        qbdsProjFundingSource.addLink(fieldNum(CustTable, AccountNum), fieldNum(ProjFundingSource, CustAccount));
        qbdsProjFundingSource.joinMode(JoinMode::ExistsJoin);
        
        // Filter by the current project
        qbdsProjFundingSource.addRange(fieldNum(ProjFundingSource, ContractId)).value(queryValue(projInvoiceTable.ProjInvoiceProjId));
        
        // Setup the lookup
        sysTableLookup = SysTableLookup::newParameters(tableNum(LogisticsElectronicAddress), ctrl);
        sysTableLookup.addLookupfield(fieldNum(LogisticsElectronicAddress, Locator));
        sysTableLookup.addLookupfield(fieldNum(LogisticsElectronicAddress, Type));
        sysTableLookup.addLookupfield(fieldNum(LogisticsElectronicAddress, Description));
        sysTableLookup.parmQuery(query);
        sysTableLookup.performFormLookup();
        
        // Mark the event as handled to prevent default lookup
        FormControlCancelableSuperEventArgs ce = e as FormControlCancelableSuperEventArgs;
        ce.CancelSuperCall();
    }

}
 
I thought D365 automatically created the hyperlinks as it also knows there is a relation but I figure Im just missing some kind of property that needs to be set?
 
Categories:
I have the same question (0)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 412 Super User 2026 Season 1

#2
Subra Profile Picture

Subra 396

#3
Martin Dráb Profile Picture

Martin Dráb 261 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans