hi

i need to create a new lookup in form. the requirement is if we select a value in InvoiceAccount field in form corresponding invoiceids should display in the InvoiceId field.

InvoiceAccount field i taken from CustInvoiceJour table and InvoiceId field is i created and i used EDT InvoiceID for that.

public static void LookupInvoiceIdbyCustAccount1(FormControl _callingControl,InvoiceId _invoiceId)
{
Query query;
QueryBuildDataSource qbds;
QueryBuildRange qbr;
SysTableLookup lookup;
;

query = new Query();
qbds = query.addDataSource(tablenum(CustInvoiceJour));
qbr = qbds.addRange(fieldnum(CustInvoiceJour,InvoiceId));
qbr.value(queryvalue(_invoiceId));

lookup = SysTableLookup::newParameters(tablenum(CustInvoiceJour), _callingControl, true);
lookup.parmQuery(query);

lookup.addLookupField(fieldnum(CustInvoiceJour,InvoiceId),true);
lookup.addLookupfield(fieldnum(CUstInvoiceJour,InvoiceAccount),true);

lookup.performFormLookup();

}

and i called this method from form control that is InvoiceId in the form.

cau anyone help me? Thankyou…

First, please think about whether “hi” is an appropriate name of a thread.

Second, can’t you simply add a composite relation to the table?

Last, I don’t see any description of what doesn’t work in your solution.

Nevertheless I noticed that you set returnItem (second parameter in addLookupField()) twice, that’s wrong. And according to your requirement, you should add range to InvoiceAccount, not InvoiceId.

sorry, for time being i wrote like that,

i blocked taht second parameter and i set the range for invoiceId.but still i am not getting the lookup in for InvoiceId field in the form.

i called this method in the form control which is InvoiceId in the datasource, i wrote like this…

public void lookup(FormControl _formControl, str _filterStr)
{
;

CustInvoiceJour::LookupInvoiceIdbyCustAccount(_formControl,CustInvoiceJour.InvoiceAccount);
super(_formControl, _filterStr);
}

can you help me in this recipe?

Thanks…

Apart from that, you should remove the call to super()…

i blocked the super in the above code with comments.

but still i am not getting the lookup in the form for InvoiceId field.

can u plz check it kranti.

It works for me so you just an error somewhere.

martin can u plz send me the code what you wrote in u r mechine?

Thanks…

martin can u plz post the code what you wrote in u r mechine?

Thanks…

I have a simplified solution - a form with one field (StringEdit, edt InvoiceId), lookup method uses a hard-coded account:

public void lookup(){ element.testLookup(this, “2202”); }

And the testLooupMethod() is your method just with the range fixed:

public void testLookup(FormControl _ctrl, CustInvoiceAccount _account)
{
    Query   query;
    QueryBuildDataSource    qbds;
    QueryBuildRange qbr;
    SysTableLookup  lookup;
    ;

    query   = new Query();
    qbds    = query.addDataSource(tablenum(CustInvoiceJour));
    qbr     = qbds.addRange(fieldnum(CustInvoiceJour,InvoiceAccount));
    qbr.value(queryvalue(_account));

    lookup  =   SysTableLookup::newParameters(tablenum(CustInvoiceJour), _ctrl, true);
    lookup.parmQuery(query);

    lookup.addLookupField(fieldnum(CustInvoiceJour,InvoiceId),true);
    lookup.addLookupfield(fieldnum(CUstInvoiceJour,InvoiceAccount),true);

    lookup.performFormLookup();
}

now my code is this,

public static void LookupInvoiceIdbyCustAccount(FormControl _callingControl,InvoiceId _invoiceId)
{
Query query;
QueryBuildDataSource qbds;
QueryBuildRange qbr;
SysTableLookup lookup;
;

query = new Query();
qbds = query.addDataSource(tablenum(CustInvoiceJour));
qbr = qbds.addRange(fieldnum(CustInvoiceJour,InvoiceAccount));
qbr.value(queryvalue(_invoiceId));

lookup = SysTableLookup::newParameters(tablenum(CustInvoiceJour), _callingControl, true);
lookup.parmQuery(query);

lookup.addLookupField(fieldnum(CustInvoiceJour,InvoiceId),true);
//lookup.addLookupfield(fieldnum(CUstInvoiceJour,InvoiceAccount),true);

lookup.performFormLookup();

}

and in the InvoiceId form control of datasource i called this method as follows

public void lookup(FormControl _formControl, str _filterStr)
{
;

CustInvoiceJour::LookupInvoiceIdbyCustAccount(_formControl,CustInvoiceJour.InvoiceAccount);
// super(_formControl, _filterStr);
}

plz check it.

Thankyou…