I have a requirement to get Customer Delivery Address in my form .
I have Customer field in my table and need to get all the delivery addresses for that customer as lookup to select for the new address field added.
Added a new field - Drag and drop ( sales line - delivery postal address field ).
maintain relation : Table.DeliveryPostalAddr == LogisticsPostalAddress.Recid.
Add the field to form at required position.
AutoDeclaration - yes to Reference Group.
Properties :
data source - Inventlocation
ReferenceField : DeliveryPostalAddr
ReplacementFieldGroup - Location Reference.
Override Lookup reference method
public Common lookupReference()
{
CustTable custTable;
DirPartyTable dirPartyTable;
DirPartyLocation dirPartyLocation;
LogisticsPostalAddress logisticsPostalAddress;
SysReferenceTableLookup sysRefTableLookup;
Query lookupQuery = new Query();
QueryBuildDataSource lookupQueryDataSource;
// Construct
the SysRefTableLookup object
sysRefTableLookup =
SysReferenceTableLookup::newParameters(tableNum(LogisticsPostalAddress),ReferenceGroup);
// Add the
field list that will be displayed on the lookup form
// You can
Change/Add more fields in lookup based on your requirement.
sysRefTableLookup.addLookupfield(fieldNum(LogisticsPostalAddress, Address));
sysRefTableLookup.addLookupfield(fieldNum(LogisticsPostalAddress,
Location));
// Construct
the query's data source
lookupQueryDataSource = lookupQuery.addDataSource(tableNum(LogisticsPostalAddress));
// To add
multiple values in range.
while
select Location from
LogisticsPostalAddress
join
DirPartyLocation
join
dirPartyTable
join
custTable
where
logisticsPostalAddress.Location == dirPartyLocation.Location
&&
dirPartyLocation.Party == custTable.Party
&& custTable.Party ==
DirPartyTable.RecId
&&
custTable.AccountNum == InventLocation.citCustAccount
{
// Add
ranges to the query data source
lookupQueryDataSource.addRange(fieldNum(LogisticsPostalAddress,
Location)).value(queryValue(LogisticsPostalAddress.Location));
}
// Pass the
query to the lookup object
sysRefTableLookup.parmQuery(lookupQuery);
return
sysRefTableLookup.performFormLookup();
}
|
Before writing custom lookup first you have to add reference control in your form and you have to specify some properties as shown in the screen shot below,
http://dynamicsaxcloud.blogspot.in/2015/06/reference-lookup-for-customer-delivery.html
No comments:
Post a Comment