info(Ledger::accountingCurrency(CompanyInfo::current());
Sometimes we need to select the records only if the field value is in a set of expected values. Microsoft Introduce In Operator in X++ in D365FO. Remember this can only be used for enum type fields
First, you need to assign containers with specified values. Here is sample code where the query selects only the records with status delivered, Sales, Invoice in where clause
static void GetAttribute(Args _args)
{
inventTable InventTable;
EcoResProductAttributeValue ecoResProductAttributeValue;
EcoResAttribute ecoResAttribute;
EcoResValue ecoResValue;
while select InventTable where InventTable.itemid == "0000001"
join RecId from ecoResProductAttributeValue
where ecoResProductAttributeValue.Product == InventTable.Product
join Name from ecoResAttribute
where ecoResProductAttributeValue.Attribute == ecoResAttribute.RecId
join ecoResValue
where ecoResValue.RecId == ecoResProductAttributeValue.Value
{
info(strFmt("%1 - %2 - %3", InventTable.ItemId, ecoResAttribute.Name, ecoResValue.value()));
}
}
Here is the X++ code to find Worker Primary Position in given date time
public static HcmWorkerPrimaryPosition findByWorker(
HcmWorkerRecId _worker,
utcdatetime _validFrom = DateTimeUtil::utcNow(),
utcdatetime _validTo = _validFrom,
boolean _forUpdate = false,
ConcurrencyModel _concurrencyModel = ConcurrencyModel::Auto)
{
HcmWorkerPrimaryPosition hcmWorkerPrimaryPosition;
hcmWorkerPrimaryPosition.selectForUpdate(_forUpdate );
if (_forUpdate && _concurrencyModel != ConcurrencyModel::Auto)
{
hcmWorkerPrimaryPosition.concurrencyModel(_concurrencyModel);
}
if (_worker)
{
if (prmisdefault(_validFrom) && prmisdefault(_validTo))
{
select firstonly hcmWorkerPrimaryPosition
where hcmWorkerPrimaryPosition.Worker == _worker;
}
else if (_validFrom == _validTo)
{
select firstonly ValidTimeState(_validFrom) hcmWorkerPrimaryPosition
where hcmWorkerPrimaryPosition.Worker == _worker;
}
else
{
select ValidTimeState(_validFrom, _validTo) hcmWorkerPrimaryPosition
where hcmWorkerPrimaryPosition.Worker == _worker;
}
}
return hcmWorkerPrimaryPosition;
}
X++ code to create default dimension in both D365FO and AX-2012
public class DefaultDimesnionHelper
{
X++ code to find employee dimension
static void employeeDim(Args _args)
Here is the X++ code to find the complete list of tables in Ax 2012 and D365FO
public void getTableList()
Args args; ReportRun report; salesLineProductPartProd salesLineProductPartProdLocal; ; ...