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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Binding Opertaion failed / Cannot select a record.

(0) ShareShare
ReportReport
Posted on by 931

Hi all,

I have a customized form where i have lookup with certain conditions with Table A and Table B.

Lets say for example, In table B, there are two fields, customer account and customer parts.

For one customer account there are 'N' number of customer parts.

My requirement is to lookup the values of customer parts based on the customer account selected.

So, in the lookup method of Table A field, i have the below code.

public void lookup(FormControl _formControl, str _filterStr)
{
    Query                   query = new Query();
    QueryBuildDataSource    qbds;
    QueryBuildDataSource    QbdsJoin;
    QueryBuildRange         qbr,qbr1;
    TableB                  tableB;
    str 64                  filterStr;
    SysTableLookup sysTableLookup = sysTableLookup::newParameters(tableNum(TableB), _formControl);
    ;

    // Create the query.
    qbds= query.addDataSource(tableNum(TableB));      

    while select forceliterals tableB
        where tableB.CustAccount == TableA.CustAccount
        {
if(tableB.extItem != "")
{ qbds.addRange(fieldNum(TableB,ExtItem)).value(tableB.ExtItem); qbds.addSortField(fieldNum(TableB,ExtItem)); qbds.orderMode(OrderMode::GroupBy); query.literals(true);
} } sysTableLookup.parmUseLookupValue(true); sysTableLookup.parmQuery(query); sysTableLookup.addLookupfield(fieldNum(TableB,ExtItem)); sysTableLookup.performFormLookup(); }

Before using forceLiterals, i got the Binding Operation failed too allocate buffer space error.

So i used forceLiterals in the select statement, then i get the error like, Cannot select a record in TableB. SQL issued an error.

The table is in proper Sync, but yet i receive this error.

Any Suggestions appreciated.

*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at
  • ThivaKar Profile Picture
    931 on at

    Can you please see my code. I already tried literals

  • ThivaKar Profile Picture
    931 on at

    I need to have a lookup based on TableB customer account and Table A customer account.

    Say, Table B is InventTable and Table A is my table.

    I have customer account field in a Invent Table and my table.

    In the form, where it use TableA(Mytable) datasource.

    The lookup field in the form should be based on the customer account selected.

    Please advice me to do this in the right way if the above is wrong

  • Verified answer
    Chaitanya Golla Profile Picture
    17,225 on at

    Hi,

    Is there any specific reason who are using while-select when join can be used and according to your requirement I don't think we require group by operation. I just modified your lookup as below, please test it and let me know if anything is missing.

    public void lookup(FormControl _formControl, str _filterStr)
    {
        Query                   query = new Query();
        QueryBuildDataSource    qbds, qbdsTableB;
        QueryBuildDataSource    QbdsJoin;
        QueryBuildRange         qbr,qbr1;
        TableB                  tableB;
        str 64                  filterStr;
        SysTableLookup sysTableLookup = sysTableLookup::newParameters(tableNum(TableB), _formControl);
        ;
        
        sysTableLookup.addLookupfield(fieldNum(TableB,ExtItem));         
        
        // Create the query.
        query.literals(true);    
        
        qbds = query.addDataSource(tableNum(TableA));      
        qbdsTableB = qbds.addDataSource(tableNum(TableB));
        qbdsTableB.addLink(fieldNum(TableA, CustAccount), fieldNum(TableB, CustAccount));
        qbdsTableB.addRange(fieldNum(tableB, extItem)).value(queryValue(TableA.CustAccount));  // Here TableA refers to datasource
        qbdsTableB.addSortField(fieldNum(TableB,ExtItem));
        //qbdsTableB.orderMode(OrderMode::GroupBy); //Removed groupby
        
        //sysTableLookup.parmUseLookupValue(true);
        sysTableLookup.parmQuery(query);
        sysTableLookup.performFormLookup();
    }


  • ThivaKar Profile Picture
    931 on at

    I need the InventTable ExtItem in the lookup based on the below logic.

    InventTable.CustAccount = MyTable.CustAccount and InventTable,.dimension[2] = MyTable.Dimension[2].

    Please let me know how to achieve this.

  • ThivaKar Profile Picture
    931 on at

    How can i add two links, custaccount and dimesions[2]

  • Chaitanya Golla Profile Picture
    17,225 on at

    Hi,

    Ok. What is Mytable here, can I assume it to as TableA.

  • ThivaKar Profile Picture
    931 on at

    Yes .. It is TableA

  • Suggested answer
    Chaitanya Golla Profile Picture
    17,225 on at

    Hi,

    Use the below code, please test it as I don't have AX4.0 to check the dimension stuff.

    public void lookup(FormControl _formControl, str _filterStr)
    {
        Query                   query = new Query();
        QueryBuildDataSource    qbds, qbdsTableB, qbdsInventTable;
        QueryBuildDataSource    QbdsJoin;
        QueryBuildRange         qbr,qbr1;
        InventTable             inventTable; 
        TableB                  tableB;
        str 64                  filterStr;
        SysTableLookup sysTableLookup = sysTableLookup::newParameters(tableNum(TableB), _formControl);
        ;
        
        sysTableLookup.addLookupfield(fieldNum(TableB,ExtItem));         
        
        // Create the query.
        query.literals(true);    
        
        qbds = query.addDataSource(tableNum(TableA));      
        qbdsTableB = qbds.addDataSource(tableNum(TableB));
        qbdsTableB.addLink(fieldNum(TableA, CustAccount), fieldNum(TableB, CustAccount));
        qbdsTableB.joinMode(JoinMode::InnerJoin);
        qbdsTableB.addRange(fieldNum(tableB, extItem)).value(queryValue(TableA.CustAccount)); //TableA is datasource
        qbdsTableB.addSortField(fieldNum(TableB,ExtItem));
        qbdsInventTable = qbds.addDataSource(tableNum(InventTable)); 
        qbdsInventTable.addLink(fieldNum(TableA, CustAccount), fieldNum(InventTable, CustAccount));
        qbdsInventTable.addLink(fieldNum(TableA, Dimension[2]), fieldNum(InventTable, Dimension[2]));
        qbdsInventTable.joinMode(JoinMode::InnerJoin);
        
        //qbdsTableB.orderMode(OrderMode::GroupBy);
        
        //sysTableLookup.parmUseLookupValue(true);
        sysTableLookup.parmQuery(query);
        sysTableLookup.performFormLookup();
    }


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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 16

#2
GiacomoRovai Profile Picture

GiacomoRovai 4

#3
Douglas Noel Profile Picture

Douglas Noel 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans