D365 F and O X++ Code
Thursday, July 13, 2023
Workflow Approver Name For PurchRequsition Order
Monday, August 29, 2022
Multi select Lookup on Form using X++
First Set a global Variable,
public SysLookupMultiSelectCtrl multicltrl;Create Lookup method to get the value in field,
public void lookup()
{
Query query;
QueryBuildDataSource queryBuildDataSource;
QueryBuildFieldList fieldList;
super();
query = new Query();
queryBuildDataSource = query.addDataSource(tableNum(CustTable));
fieldList = queryBuildDataSource.fields();
fieldList.addField(fieldNum(CustTable,AccountNum));
fieldList.addField(fieldNum(CustTable,CustGroup));
fieldList.addField(fieldNum(CustTable,RecId));
fieldList.dynamic(QueryFieldListDynamic::No);
container selectedField = [tableNum(CustTable), fieldNum(CustTable,AccountNum)];
multicltrl = SysLookupMultiSelectCtrl::constructWithQuery(this.formRun(),this,query,false,selectedField);
}
Create Modified Method to set the value in field,
public boolean modified()
{
boolean ret;
ret = super();
TestTable.CustomField = con2Str(multicltrl.getSelectedFieldValues(), ';');
return ret;
}
Process,
Click on Form Field Lookup button,
Enjoy 👍
Using COC
[ExtensionOf(formDataFieldStr(ProjTableCreate, ProjTable, GropId))]
final class FormDataSource_Extension
{
public SysLookupMultiSelectCtrl multicltrl;
public void lookup(FormControl _formControl, str _filterStr)
{
Query query;
QueryBuildDataSource queryBuildDataSource;
QueryBuildFieldList fieldList;
FormRun localFormRun = _formControl.formRun();
next lookup(_formControl,_filterStr);
query = new Query();
queryBuildDataSource = query.addDataSource(tableNum(ProjValProjCategoryTable));
fieldList = queryBuildDataSource.fields();
fieldList.addField(fieldNum(ProjValProjCategoryTable, GroupId));
fieldList.addField(fieldNum(ProjValProjCategoryTable, Name));
fieldList.dynamic(QueryFieldListDynamic::No);
container selectedField = [tableNum(ProjValProjCategoryTable), fieldNum(ProjValProjCategoryTable, GroupId)];
multicltrl = SysLookupMultiSelectCtrl::constructWithQuery(localFormRun,_formControl,query,false,selectedField);
}
/// <summary>
///
/// </summary>
public void modified()
{
FormDataObject formDataObject = any2Object(this) as FormDataObject;
FormDataSource formDataSource = formDataObject.datasource();
ProjTable projTable;
next modified();
projTable = formDataSource.cursor();
projTable.GropId = con2Str(multicltrl.getSelectedFieldValues(), ';');
}
}
Tuesday, November 23, 2021
Pass Multi Line Record Using Button Clicked
Pass multi
Line Record using Button
Form A Button clicked Method:void clicked()
{
int recordsCount;
SalesLine _salesLine;
container con;
Args args;
str multiSelectString;
args = new Args();
recordsCount = SalesLine_1_ds.recordsMarked().lastIndex(); // gets the total records selected
_salesLine = SalesLine_1_ds.getFirst(1);
while (_salesLine)
{
con = conIns(con, 1, _salesLine.RecId);
multiSelectString = con2Str(con, ",");
_salesLine = SalesLine_1_ds.getNext(); // moves to next record
}
args.parm(multiSelectString);
new MenuFunction(menuitemDisplayStr(GofyndSalesOrderError), MenuItemType::Display).run(args);
}
Form B Init Method:
public void init()
{
super();
multipleRecords = element.args().parm();
con = str2con(multipleRecords,",");
for(i = 1; i<= conLen(con);i++)
{
SalesLine_ds.query().dataSourceTable(Tablenum(SalesLine)).addRange(fieldNum(SalesLine,RecId)).value(SysQuery::value(conPeek(con,i)));
SalesLine_ds.query().dataSourceTable(tableNum(SalesLine)).addRange(fieldNum(SalesLine,S3_GofyndError)).value(sysquery::valueNotEmptyString());
}
}
Sunday, August 1, 2021
Tax Details Using X++
Thursday, July 29, 2021
Simple List Form With Multi Filters
Filter Form Look:
Modified Method:
public boolean modified()
{
boolean ret;
ret = super();
PurchTable_DS.executeQuery();
return ret;
}
Lookup Method:
public void lookup()
{
Query query = new Query();
super();
SysTableLookup SysTableLookup = SysTableLookup::newParameters(tableNum(TableName),this);
QueryBuildDataSource qbds = query.addDataSource(tableNum(TableName));
SysTableLookup.addLookupfield(fieldNum(TableName,Field1));
SysTableLookup.addLookupfield(fieldNum(TableName,Field2));
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}
Execute Query Method:
public void executeQuery()
{
PurchTable_DS.query().dataSourceName('PurchTable').clearRanges();
PurchTable_DS.init();
if(VendAccount.valueStr())
{
str account = VendAccount.valueStr();
if(account != '0')
this.query().dataSourceTable(tableNum(PurchTable)).addRange(fieldNum(PurchTable, OrderAccount)).value(account);
}
if(PurchType.valueStr())
{
this.query().dataSourceTable(tableNum(PurchTable)).addRange(fieldNum(PurchTable, PurchStatus)).value(PurchType.valueStr());
}
if(InventSiteId.valueStr())
{
str site = InventSiteId.valueStr();
this.query().dataSourceTable(tableNum(PurchTable)).addRange(fieldNum(PurchTable,InventSiteId)).value(site);
}
if (monthfilter.valueStr())
{
TransDate lastDate = endMth(monthfilter.dateValue());
TransDate startDate = dateStartMth(monthfilter.dateValue());
this.query().dataSourceTable(tablenum(PurchTable)).addRange(fieldnum(PurchTable, DeliveryDate)).value(sysQuery::range(startDate, lastDate));
}
if (!monthfilter.valueStr())
{
TransDate lastDate ;
TransDate startDate;
if(dayOfMth(today()) <16)
{
lastDate = mkDate(15,mthOfYr(today()),Year(today()));
startDate = mkDate(16,mthOfYr(today())-1,Year(today()));
}
if(dayOfMth(today()) >15)
{
lastDate = mkDate(15,mthOfYr(today())+1,Year(today()));
startDate = mkDate(16,mthOfYr(today()),Year(today()));
}
this.query().dataSourceTable(tablenum(PurchTable)).addRange(fieldnum(PurchTable, DeliveryDate)).value(sysQuery::range(startDate, lastDate));
} this.query().dataSourceTable(tableNum(PurchTable)).addSortField(fieldNum(PurchTable,DeliveryDate),SortOrder::Descending);
super();
}
/// Enjoy 👍
Wednesday, July 28, 2021
Lookup On Form Extension using Event Handler
Check the Event handler Code,
[FormControlEventHandler(formControlStr(BankParameters, JournalName_VendPaymJourName), FormControlEventType::Lookup)]
public static void JournalName_VendPaymJourName_OnLookup(FormControl sender, FormControlEventArgs e)
{
Query query = new Query();
QueryBuildDataSource queryBuildDataSource;
QueryBuildRange queryBuildRange;
SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(LedgerJournalName), sender);
sysTableLookup.addLookupField(fieldNum(LedgerJournalName, JournalName));
sysTableLookup.addLookupField(fieldNum(LedgerJournalName, Name));
queryBuildDataSource = query.addDataSource(tableNum(LedgerJournalName));
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}
Enjoy .👍
Tuesday, June 8, 2021
Some Code Example For SSRS Report Data for Transfer Order:
Check Code,
If we are going to find tax data for the transfer order then I think you have RecID of particular Invoiced Transfer Order lets move to the data and some X++ code to find the data in D365 F and O
HSN Code
HSN = HSNCodeTable_IN::find(this.GetHSNCode(inventTransferLine));
RefRecId GetHSNCode(InventTransferLine inventTransferLine){
TransTaxInformation taxInfo;
TransTaxInformationRelationView taxRelation;
select firstonly1 taxRelation
where taxRelation.TransactionRefRecId == inventTransferLine.RecId
&& taxRelation.TransactionRefTableId == tablenum(InventTransferLine)
join taxInfo
where taxInfo.RecId == taxRelation.TransTaxInformationRefRecId;
return taxInfo.HSNCodeTable;
}
ServiceAccountingCode
SAC = ServiceAccountingCodeTable_IN::find(this.GetServiceAccountingCode(inventTransferLine));
RefRecId GetServiceAccountingCode(InventTransferLine inventTransferLine){
TransTaxInformation taxInfo;
TransTaxInformationRelationView taxRelation;
select firstonly1 taxRelation
where taxRelation.TransactionRefRecId == inventTransferLine.RecId
&& taxRelation.TransactionRefTableId == tablenum(InventTransferLine)
join taxInfo
where taxInfo.RecId == taxRelation.TransTaxInformationRefRecId;
return taxInfo.ServiceAccountingCodeTable;
}
NetAmount
InventTransferJourLine_IN::findByInventTransferJourLineRecId(inventTransferJournLine.RecId).AssessableValue;
Tax Rate
line.CGSTRate = abs(this.TaxRate(inventTransferJournLine,'CGST', line.NetAmount));line.SGSTRate = abs(this.TaxRate(inventTransferJournLine,'SGST', line.NetAmount)); line.IGSTRate = abs(this.TaxRate(inventTransferJournLine,'IGST', line.NetAmount));
str _component,
Amount _netAmount)
{
TaxTrans taxtrans, taxtransvalue;
select sum(SourceRegulateAmountCur),TaxValue,SourceRecid from taxtrans
where taxtrans.InventTransId == _inventTransferJournLine.InventTransID
&& taxtrans.Voucher == _inventTransferJournLine.VoucherId
&& taxtrans.TaxCode == _component;
select taxtransvalue where taxtransvalue.inventtransid == _inventTransferJournLine.InventTransID
&& taxtransvalue.Voucher == _inventTransferJournLine.VoucherId
&& taxtransvalue.TaxCode == _component;
return abs(taxtransvalue.TaxValue);
line.SGST = abs(this.TaxAmount(inventTransferJournLine,'SGST', line.NetAmount));
str _component,
Amount _netAmount)
{
TaxTrans taxtrans, taxtransvalue;
select sum(SourceRegulateAmountCur),TaxValue,SourceRecid from taxtrans
where taxtrans.InventTransId == _inventTransferJournLine.InventTransID
&& taxtrans.Voucher == _inventTransferJournLine.VoucherId
&& taxtrans.TaxCode == _component;
select taxtransvalue where taxtransvalue.inventtransid == _inventTransferJournLine.InventTransID
&& taxtransvalue.Voucher == _inventTransferJournLine.VoucherId
&& taxtransvalue.TaxCode == _component;
return abs(taxtrans.SourceRegulateAmountCur);
Workflow Approver Name For PurchRequsition Order
For First Approver, this.workflowApprover(purchReqTable.RecId); public void workflowApprover (RecId _recId) // Requsation Table RecId ...
-
From Tax Document You have to Use TaxDocumentLauncher Class. this.taxData(purchReqLine,purchReqHead); public void taxData(PurchReqLine ...
-
First Set a global Variable, public SysLookupMultiSelectCtrl multicltrl; Create Lookup method to get the value in field, public ...
-
display EDT getSum(EDT ID ) { Table table; EDT field; select Sum(Field) from table where t...