Hi
I am creating override lookup form method and am trying to show the second column field value in a lookup in AX 2012. This screenshot just to show u reference.
I need to get the second field value on selected record in the lookup .
*This post is locked for comments
Hi,
I know it is very old post, but I'm new in AX. I have solution sth like this to your problem:
1. Find DS and field whose is ID on lookup and override modified() method
<img src="imgur.com/.../hQSBhhN" />
2. Use Select to find your field (this is example for this screen)
public void modified()
{
smmBusRelTable sBRelTable;
DirPartyTable dPartyTable;
super();
select Party from sBRelTable //RecId
where sBRelTable.BusRelAccount == GoExperience_GoCompanyCode.valueStr() // GoExperience_GoCompanyCode - value on design/grid
join Name from dPartyTable
where dPartyTable.RecId == sBRelTable.Party; //Party is as RecId field
GoExperience.GoCompanyName = dPartyTable.Name; //and now it's working
GoParticipants_ds.refresh();
GoParticipants_ds.research();
}
Regards
Hi Priyabrata
If I am right your are trying to display Description field to user and store Name in table ?
For this requirement you have to use replacement group
You can find more details on below link
Hi Priyabrata,
Modify the code as follows:
Your lookup method should be:
Query query = new Query(); QueryBuildDataSource queryBuildDataSource; SysTableLookup sysTableLookup = sysTableLookup::newParameters(tableNum(InventSite), this); ; sysTableLookup.addLookupfield(fieldNum(InventSite, SiteId), true); sysTableLookup.addLookupfield(fieldNum(InventSite, Name)); queryBuildDataSource = query.addDataSource(tableNum(InventSite)); queryBuildDataSource.addSortField(fieldnum(InventSite, SiteId)); queryBuildDataSource.addOrderByField(fieldnum(InventSite, Name)); queryBuildDataSource.orderMode(OrderMode::GroupBy);//Used to Group the Field Value sysTableLookup.parmQuery(query); sysTableLookup.performFormLookup();Create a new class with the following code:
class LookupFormClass { public InventSiteName getInventSiteName(InventSiteId _inventSiteId) { return InventSite::find(_inventSiteId).Name; } }Now override the modified method in your field:
public boolean modified() { boolean ret; LookupFormClass obj; ret = super(); if (ret) { obj = new LookupFormClass(); this.text(obj.getInventSiteName(this.text())); } return ret; }Hope that helps!
Hi Ammar
I have tried this one it's not working my code is:-
But, I need save the invoice Id other than name, in text field i can fetch the name but in table, i need to fetch the id.
Query query = new Query();
QueryBuildDataSource queryBuildDataSource;
SysTableLookup sysTableLookup = sysTableLookup::newParameters(tableNum(InventSite), this);
;
sysTableLookup.addLookupfield(fieldNum(InventSite, SiteId));
sysTableLookup.addLookupfield(fieldNum(InventSite, Name), true);
queryBuildDataSource = query.addDataSource(tableNum(InventSite));
queryBuildDataSource.addSortField(fieldnum(InventSite, SiteId));
queryBuildDataSource.addOrderByField(fieldnum(InventSite, Name));
queryBuildDataSource.orderMode(OrderMode::GroupBy);//Used to Group the Field Value
sysTableLookup.parmQuery(query);
SysTableLookup.parmUseLookupValue(false);
sysTableLookup.performFormLookup();
Please suggest the solution.
Hi Priyabrata,
I am assuming you are using SysTableLookup class to implement your lookup.
You can set the second parameter to "true" while adding columns to your lookup.
Please refer to the below sample code:
public void lookup() { //super(); SysTableLookup lookup = SysTableLookup::newParameters(tableNum(CustInvoiceJour), this); lookup.addLookupfield(fieldNum(CustInvoiceJour, InvoiceId)); lookup.addLookupfield(fieldNum(CustInvoiceJour, InvoicingName), true); //returns the Invoicing Name lookup.performFormLookup(); }Hope that helps!
In InventJournalTable form, lookup method for the JournalNameId field is overwritten, you'll need to modify the designLookupJournalName method from the JournalFormTable class, ence you'll have to take a look at the JournalStatic class
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156