Tuesday, January 31, 2023

How to get vendor name of a purchase order in lookup from logisticslocation using X++

 [FormControlEventHandler(formControlStr(PurchTable, PurchTable_Description), FormControlEventType::Lookup)]   

public static void PurchTable_Description_OnLookup(FormControl sender, FormControlEventArgs e) 

{        

VendTable    vendTable;        

PurchTable  purchTable,purchTable1; 

TaxInformation_IN    taxInformation_IN;        

LogisticsLocation    logisticsLocation;                

 DirPartyTable  dirPartyTable;        

TaxInformationName  tax;        

str name1;           

FormStringControl Name;        

Query query = new Query();        

QueryBuildDataSource queryBuildDataSource;        

QueryBuildRange queryBuildRange;        

SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(LogisticsLocation), sender);        

FormRun formRun;        

formRun = sender.formRun();        

purchTable  = formRun.dataSource().cursor();        

vendTable= vendTable::find(purchTable.OrderAccount);        

dirPartyTable = DirPartyTable::findRec(vendTable.Party);        

logisticsLocation = LogisticsLocation::find(dirPartyTable.PrimaryAddressLocation);        

taxInformation_IN = TaxInformation_IN::findDefaultbyLocation(logisticsLocation.RecId);          

queryBuildDataSource = query.addDataSource(tableNum(TaxInformation_IN));        

sysTableLookup.addLookupField(fieldNum(LogisticsLocation,Description));          

queryBuildRange = queryBuildDataSource.addRange(fieldNum(LogisticsLocation,RecId));        

queryBuildRange.value(SysQuery::value(tlogisticsLocation.RecId));        

sysTableLookup.parmQuery(query);        

sysTableLookup.performFormLookup();    

}

How to get particular vendor tax information of a purchase order in lookup from TaxInformation_In using x++

[FormControlEventHandler(formControlStr(PurchTable, PurchTable_Description), FormControlEventType::Lookup)]   

public static void PurchTable_Description_OnLookup(FormControl sender, FormControlEventArgs e) 

{        

VendTable   vendTable;        

PurchTable  purchTable,purchTable1; 

TaxInformation_IN   taxInformation_IN;        

LogisticsLocation   logisticsLocation;                

 DirPartyTable  dirPartyTable;        

TaxInformationName  tax;        

str name1;           

FormStringControl Name;        

Query query = new Query();        

QueryBuildDataSource queryBuildDataSource;        

QueryBuildRange queryBuildRange;        

SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(TaxInformation_IN), sender);        

FormRun formRun;        formRun = sender.formRun();        

purchTable     = formRun.dataSource().cursor();        

vendTable= vendTable::find(purchTable.OrderAccount);        

dirPartyTable = DirPartyTable::findRec(vendTable.Party);        

logisticsLocation = LogisticsLocation::find(dirPartyTable.PrimaryAddressLocation);        

taxInformation_IN = TaxInformation_IN::findDefaultbyLocation(logisticsLocation.RecId);          

queryBuildDataSource = query.addDataSource(tableNum(TaxInformation_IN));        

sysTableLookup.addLookupField(fieldNum(TaxInformation_IN, Name));          

queryBuildRange = queryBuildDataSource.addRange(fieldNum(TaxInformation_IN,RecId));        

queryBuildRange.value(SysQuery::value(taxInformation_IN.RecId));        

sysTableLookup.parmQuery(query);        

sysTableLookup.performFormLookup();    

Thursday, January 26, 2023

How to get one form controls in other form in D365

How to get one form controls in other form in D365    



FormRun formRunloc;

formRunloc = this.formRun().args().caller();

 FormStringControl  nameloc =   formRunloc .design().controlName(formControlStr(PurchTable,Name1));

FormStringControl  nameloc1 = formRunloc .design().controlName(formControlStr(PurchTable,Description));

Wednesday, January 18, 2023

How to get all dimension values assigned to Customer / Vendor- Dynamics 365 for finance and operations



public static void main(Args _args)
{

DefaultDimensionView defaultDimensinView;
CustTable custTable;
select DefaultDimension from custTable where custTable.AccountNum ==’CUS-000001′;
while select Name, DisplayValue from defaultDimensinView
where defaultDimensinView.DefaultDimension == custTable.DefaultDimension
{

Info (defaultDimensinView.Name +” ” + defaultDimensinView.DisplayValue);

}

}