To run report based on the print management setting
Refer WHSPickListShippingController
And change enum parameters in the output menu item to originalprint.
To run report based on the print management setting
Refer WHSPickListShippingController
And change enum parameters in the output menu item to originalprint.
shrink db log
ALTER DATABASE DYNAMICSXREFDB SET RECOVERY SIMPLE WITH NO_WAIT
DBCC SHRINKFILE(DYNAMICSXREFDB_log, 1000)
ALTER DATABASE DYNAMICSXREFDB SET RECOVERY FULL WITH NO_WAIT
Create default dimensions in d365fo x++
public DimensionDefault createDefaultDimension(DimensionValue _CostC,
DimensionValue _department,
DimensionValue _branchCode )
{
DimensionAttributeValueSetStorage valueSetStorage = new DimensionAttributeValueSetStorage();
DimensionDefault ddim;
int i;
DimensionAttribute dimensionAttribute;
DimensionAttributeValue dimensionAttributeValue;
container conAttr = ['CostCenter','Department','BranchCode'];
container conValue = [_CostC, _department, _branchCode];
str dimValue;
for (i = 1; i <= conLen(conAttr); i++)
{
dimensionAttribute = dimensionAttribute::findByName(conPeek(conAttr,i));
if (dimensionAttribute.RecId == 0)
{
continue;
}
dimValue = conPeek(conValue,i);
if (dimValue != '')
{
dimensionAttributeValue = dimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute,dimValue,false,true);
valueSetStorage.addItem(dimensionAttributeValue);
}
}
ddim = valueSetStorage.save();
return ddim;
}
Get field Id
DictTable dt;
fieldId fId;
dt = new DictTable(tablenum(VendTable));
if (dt)
{
fId = dt.fieldName2Id("Name");
print (strfmt("fId: %1", fId));
}
public void createTaxJournal(AirSalesTable _airSales, AirAmountTable _airAmount, LedgerJournalTable ljt,Amount salesAmount,RefRecId leddim,
Voucher _voucher,DebitCredit _debitCredit ,TaxEngineTaxJournalAccountType accountType ,SAC_IN _sacCode ,Amount _gstBaseAmount,NoYes _gstApplicable,RefRecId _offsetLedgerDim )
{
TaxEngineTaxJournal taxEngineTaxJournal;
TaxEngineTaxJournalLine taxEngineTaxJournalLine;
TaxEngineTaxJournalLineTaxExtensionIN taxEngineTaxJournalLineTaxExtensionIN;
LedgerJournalName ledgerJournalName;
TradeGLSetupParameters tradeGLParameters;
TaxInformation_IN taxInformation_IN;
TaxRuntimeDocComponent taxRuntimeDocComponent;
TransTaxInformation transTaxInformation;
TaxComponentTable_IN taxComponentTable_IN;
TaxRuntimePostingType taxRuntimePostingType;
TaxRuntimeDocTaxType taxRuntimeDocTaxType;
TaxEngineTaxJournalConstructor taxEngineTaxJournalConstructor;
select firstonly SalesTaxJournal,SAC from tradeGLParameters ;
_sacCode = tradeGLParameters.SAC;
select ledgerJournalName where ledgerJournalName.JournalName == tradeGLParameters.SalesTaxJournal
&& ledgerJournalName.DataAreaId == _airSales.CompanyCode;
taxEngineTaxJournal.clear();
taxEngineTaxJournalLine.clear();
taxEngineTaxJournal.initValue();
taxEngineTaxJournal.defaultRow();
//taxEngineTaxJournal.JournalNum = JournalTableData::newTable(taxEngineTaxJournal).nextJournalId();
taxEngineTaxJournal.JournalNum = TaxEngineTaxJournalUtil::getTaxJournalNum();
taxEngineTaxJournal.insert();
//NumberSeq::newGetNum(LedgerParameters::numRefJournalNum()).parmRefTableNum(;
taxEngineTaxJournalLine.TaxEngineTaxJournal = taxEngineTaxJournal.RecId;
taxEngineTaxJournalLine.Purpose = TaxDocumentPurpose::Transaction;
taxEngineTaxJournalLine.TransDate = _airSales.ProcessedDate;
taxEngineTaxJournalLine.Description = _airSales.BookingNo;
taxEngineTaxJournalLine.CurrencyCode = _airSales.CurrencyCode;
taxEngineTaxJournalLine.Triangulation = Currency::triangulation(taxEngineTaxJournalLine.CurrencyCode);
taxEngineTaxJournalLine.ExchRate = ExchangeRateHelper::exchRate(taxEngineTaxJournalLine.CurrencyCode, taxEngineTaxJournalLine.TransDate, Currency::noYes2UnknownNoYes(taxEngineTaxJournalLine.Triangulation));
taxEngineTaxJournalLine.AccountType = TaxEngineTaxJournalAccountType::Tax;
taxEngineTaxJournalLine.LedgerDimension = leddim;
if(_airAmount.TotalCgst != 0)
{
select RecId from taxRuntimeDocComponent where taxRuntimeDocComponent.Name == "CGST";
}
else if(_airAmount.Totaligst != 0)
{
select RecId from taxRuntimeDocComponent where taxRuntimeDocComponent.Name == "IGST" ;
}
if(_airAmount.TotalSgst != 0)
{
select RecId from taxRuntimeDocComponent where taxRuntimeDocComponent.Name == "SGST" ;
}
taxEngineTaxJournalLine.TaxComponent = taxRuntimeDocComponent.RecId;
select firstonly RecId from taxRuntimePostingType where taxRuntimePostingType.Name == "Tax Payable";
taxEngineTaxJournalLine.TaxPostingType = taxRuntimePostingType.RecId;
taxEngineTaxJournalLine.OffsetAccountType = TaxEngineTaxJournalAccountType::Ledger;
taxEngineTaxJournalLine.OffsetLedgerDimension = _offsetLedgerDim;
//taxEngineTaxJournalLine.TaxMeasure =
//TaxEngineTaxJournalUtil::("GST", TaxEngineTaxJournalLine.OffsetTaxComponent);
//taxEngineTaxJournalLine. = _airSales.CompanyCode;
//ledgerJournalTrans.ExchRate = exchRate;
//taxEngineTaxJournalLine.LineNum++;
//ledgerJournalTrans.Voucher = Numberseq::newGetVoucherFromCode(NumberSequenceTable::find(ledgerJournalTable.ledgerJournalName().NumberSequenceTable).NumberSequence).voucher();//bookingTable.MODocNum;
//taxEngineTaxJournalLine.Voucher = _voucher;
//ledgerJournalTrans.DocumentDate = DateTimeUtil::getSystemDate(DateTimeUtil::getUserPreferredTimeZone());
if(_debitCredit == DebitCredit::Credit)
{
taxEngineTaxJournalLine.AmountCurCredit = salesAmount;
}
else
{
taxEngineTaxJournalLine.AmountCurDebit = salesAmount;
}
taxEngineTaxJournalLine.insert();
taxEngineTaxJournalConstructor = TaxEngineTaxJournalConstructor::construct(taxEngineTaxJournalLine.TaxEngineTaxJournal().JournalType);
//taxEngineTaxJournalConstructor.(taxEngineTaxJournalLine);
taxEngineTaxJournalLine.update();
//taxEngineTaxJournalLineTaxExtensionIN = taxEngineTaxJournalLine.TaxEngineTaxJournal();
taxEngineTaxJournalLineTaxExtensionIN.TaxEngineTaxJournalLine = taxEngineTaxJournalLine.RecId;
taxEngineTaxJournalLineTaxExtensionIN.insert();
transTaxInformation = TransTaxInformationHelper::findOrCreateTransTaxInformationByRecord(taxEngineTaxJournalLine,true);
transTaxInformation.ServiceAccountingCodeTable = ServiceAccountingCodeTable_IN::findByServiceAccountingCode(_sacCode);
transTaxInformation.update();
//TaxEngineTaxJournalUtil::postTaxJournal(taxEngineTaxJournal);
}
Department lookup
public void lookup()
{
Query query = new Query();
QueryBuildDataSource qbds;
SysTableLookup sysTableLookup;
sysTableLookup = sysTableLookup::newParameters(tableNum(OMOperatingUnit),this);
sysTableLookup.addLookupfield(fieldNum(OMOperatingUnit,OMOperatingUnitNumber));
sysTableLookup.addLookupfield(fieldNum(OMOperatingUnit,Name));
sysTableLookup.addLookupfield(fieldNum(OMOperatingUnit,OMOperatingUnitType));
sysTableLookup.addSelectionField(fieldNum(OMOperatingUnit,Name));
qbds = query.addDataSource(tableNum(OMOperatingUnit));
qbds.addSortField(fieldNum(OMOperatingUnit,OMOperatingUnitNumber));
qbds.addRange(fieldNum(OMOperatingUnit,OMOperatingUnitType)).value(enum2str(OMOperatingUnitType::OMDepartment));
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}
Delete model from D365 FO
CMD - Run as admin
Change path respectivly - K:\AosService\PackagesLocalDirectory\bin
ModelUtil.exe -delete -metadatastorepath="K:\AOSService\PackagesLocalDirectory" -modelname="xxxx"
create default dimensions
private RefRecId createPurchDefaultDimensions(OMOperatingUnitNumber _dept, DimensionValue _vehicleDim)
{
DimensionAttributeValueSetStorage dimStorage;
RefRecId defaultDimensionLoc;
Counter i;
DimensionAttribute dimensionAttribute;
DimensionAttributeValue dimensionAttributeValue;
DimensionAttributeValueSetItem dimensionAttributeValueSetItem;
DimensionAttributeValueSetStorage valueSetStorage = new DimensionAttributeValueSetStorage();
DimensionDefault defaultDim;
container conAttribute, conAttributeValue;
DimensionValue deptLoc,vehicleDim;
deptLoc = _dept;
vehicleDim = _vehicleDim;
conAttribute = conNull();
conAttributeValue = conNull();
conAttribute = conIns(conAttribute,1,'Department');
conAttributeValue = conIns(conAttributeValue, 1, deptLoc);
conAttribute = conIns(conAttribute,2,'Vehicles');
conAttributeValue = conIns(conAttributeValue, 2, vehicleDim);
for (i = 1; i <= conLen(conAttribute); i++)
{
dimensionAttribute = dimensionAttribute::findByName(conPeek(conAttribute,i));
if (dimensionAttribute.RecId == 0)
{
continue;
}
if (conPeek(conAttributeValue,i) != "")
{
dimensionAttributeValue = dimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute,conPeek(conAttributeValue,i),false,true);
valueSetStorage.addItem(dimensionAttributeValue);
}
defaultDimensionLoc = valueSetStorage.save();
}
return defaultDimensionLoc;
}
split default dimensions in ax 2012
static void splitDimAndExport(Args _args)
{
DimensionAttributeValueSetStorage dimStorage;
DimensionValue bu,costCenter,cust,custbu,custsow,dept,fa,fda,ir,inv,proj,purpose,rda,vend,worker;
Counter i;
ProjTable projTable;
// DimensionDefault is a RecId that combines all Dimension Values
while select projTable where projTable.ProjId == '201P000134-01'
{
dimStorage = DimensionAttributeValueSetStorage::find(projTable.DefaultDimension);
for (i= 1 ; i<= dimStorage.elements() ; i++)
{
// Change the string "CostCenter" to whatever financial dimension you want
if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "BusinessUnit")
{
bu = '';
bu = dimStorage.getDisplayValueByIndex(i);
}
if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "CostCenter")
{
costCenter = '';
costCenter = dimStorage.getDisplayValueByIndex(i);
}
if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "Customer")
{
cust = '';
cust = dimStorage.getDisplayValueByIndex(i);
}
if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "Customer_BU")
{
custbu = '';
custbu = dimStorage.getDisplayValueByIndex(i);
}
if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "Customer_SOW")
{
custsow = '';
custsow = dimStorage.getDisplayValueByIndex(i);
}
if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "Department")
{
dept = '';
dept = dimStorage.getDisplayValueByIndex(i);
}
if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "FixedAsset")
{
fa = '';
fa = dimStorage.getDisplayValueByIndex(i);
}
if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "FixedDepositAccount")
{
fda = '';
fda = dimStorage.getDisplayValueByIndex(i);
}
if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "InterestReceivable")
{
ir = '';
ir = dimStorage.getDisplayValueByIndex(i);
}
if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "Investors")
{
inv = '';
inv = dimStorage.getDisplayValueByIndex(i);
}
if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "Project")
{
proj = '';
proj = dimStorage.getDisplayValueByIndex(i);
}
if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "Purpose")
{
purpose = '';
purpose = dimStorage.getDisplayValueByIndex(i);
}
if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "RecurringDepositaccount")
{
rda = '';
rda = dimStorage.getDisplayValueByIndex(i);
}
if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "Vendor")
{
vend = '';
vend = dimStorage.getDisplayValueByIndex(i);
}
if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "Worker")
{
worker = '';
worker = dimStorage.getDisplayValueByIndex(i);
}
}
info(strFmt("%1 , %2 , %3 , %4 , %5 , %6 , %7 , %8 , %9 , %10 , %11 , %12, %13, %14 , %15 ",bu,costCenter,cust,custbu,custsow,dept,fa,fda,ir,inv,proj,purpose,rda,vend,worker));
}
}
User roles
static void userRoles(Args _args)
{
UserInfo userInfo;
SecurityUserRole securityUserRole;
SecurityRole securityRole;
str st;
;
st = ',';
while
select userInfo
join securityUserRole
where securityUserRole.User == userInfo.Id
{
securityRole = null;
select securityRole
where securityRole.RecId == securityUserRole.SecurityRole;
if (securityRole)
{
//info(securityRole.AotName);
//info(securityRole.Name);
info(strFmt("%1 , %2 , %3",userInfo.Id,securityRole.Name,securityRole.Description)); //info(securityRole.Description);
}
}
}
Customize class in D365 FO
1. create a extension of the standard class
2. use the expresions show
[ExtensionOf(classStr(BusinessLogic1))] final class BusinessLogic1_Extension { str doSomething(int arg) { // Part 1 var s = next doSomething(arg + 4); // Part 2 return s; } }
fromCurrecncy = projTable.currencyId();
toCurrency = Ledger::findByLegalEntity(CompanyInfo::findDataArea(curext()).RecId).AccountingCurrency;
if(fromCurrecncy != toCurrency)
{
select ExchangeRate,ExchangeRateCurrencyPair from exchangeRate order by RecId desc
join RecId,ExchangeRateDisplayFactor,ToCurrencyCode,FromCurrencyCode from exchangeRateCurrencyPair
join RecId,Name from exchangeRateType where exchangeRate.ExchangeRateCurrencyPair == exchangeRateCurrencyPair.RecId
&& exchangeRateType.RecId == exchangeRateCurrencyPair.ExchangeRateType
&& exchangeRateType.Name == 'Default'
&& exchangeRateCurrencyPair.FromCurrencyCode == fromCurrecncy
&& exchangeRateCurrencyPair.ToCurrencyCode == toCurrency;
conRevenueAmount = (exchangeRate.ExchangeRate * revenueAmount1)/minOne(exchangeRateCurrencyPair.ExchangeRateDisplayFactor);
conRevAmount = strFmt("%1",conRevenueAmount);
curExRate = strFmt("%1",exchangeRate.ExchangeRate);
}