20 August 2018

Deploy SSRS reports using powershell in Dynamics 365 Finance and Operations

Run power shell as an admin and run below command (change path if needed) J:\AosService\PackagesLocalDirectory\Plugins\AxReportVmRoleStartupTask\DeployAllReportsToSSRS.ps1 -PackageInstallLocation “J:\AosService\PackagesLocalDirectory”

08 August 2018

X++ code to release product in AX 2012 | D365

static void ReleaseProducts_detailed(Args _args)
{
EcoResProduct ecoResProduct;
InventTable inventTable;
InventTableModule inventTableModule;
NumberSequenceTable numberSequenceTable;
ItemId itemId;
InventItemSetupSupplyType inventItemSetupSupplyType;

EcoResStorageDimensionGroupProduct ecoResStorageDimensionGroupProduct;
EcoResTrackingDimensionGroupProduct ecoResTrackingDimensionGroupProduct;
EcoResStorageDimensionGroupItem ecoResStorageDimensionGroupItem;
EcoResTrackingDimensionGroupItem ecoResTrackingDimensionGroupItem;
;

select firstOnly ecoResProduct where EcoResProduct.DisplayProductNumber == "20003"; //Audio system

changecompany ('RAX')
{
ttsBegin;
inventTable = null;
inventTableModule = null;
inventItemSetupSupplyType = null;
ecoResStorageDimensionGroupProduct = null;
ecoResTrackingDimensionGroupProduct = null;
ecoResStorageDimensionGroupItem = null;
ecoResTrackingDimensionGroupItem = null;

numberSequenceTable = InventParameters::numRefItemId().numberSequenceTable();
//get item id from:
//1. Product number if number seq for item ID is not set up or manual or return blank value
if (!numberSequenceTable.RecId || numberSequenceTable.Manual)
{
itemId = ecoResProduct.productNumber();
}
else //number sequence auto, get a number
{
itemId = NumberSeq::newGetNumFromId(numberSequenceTable.RecId).num();
}

inventTable.initValue();
inventTable.initFromEcoResProduct(ecoResProduct);
inventTable.ItemId = ItemId;
inventTable.NameAlias = ecoResProduct.SearchName;
inventTable.insert(true);

// Create inventTableModules

inventTableModule.initValue();
inventTableModule.ItemId = inventTable.ItemId;
inventTableModule.ModuleType = ModuleInventPurchSales::Invent;
inventTableModule.insert();

inventTableModule.initValue();
inventTableModule.ItemId = inventTable.ItemId;
inventTableModule.ModuleType = ModuleInventPurchSales::Purch;
inventTableModule.insert();

inventTableModule.initValue();
inventTableModule.ItemId = inventTable.ItemId;
inventTableModule.ModuleType = ModuleInventPurchSales::Sales;
inventTableModule.insert();

//Create inventItemLocation
InventItemLocation::createDefault(inventTable.ItemId);

// Creates a new item default order type for the product that is released.

inventItemSetupSupplyType.initValue();
inventItemSetupSupplyType.ItemId = inventTable.ItemId;
inventItemSetupSupplyType.ItemDataAreaId = inventTable.DataAreaId;
inventItemSetupSupplyType.insert();

//create relationship tables to dimension groups.

ecoResStorageDimensionGroupProduct = EcoResStorageDimensionGroupProduct::findByProduct(ecoResProduct.RecId);
ecoResTrackingDimensionGroupProduct = EcoResTrackingDimensionGroupProduct::findByProduct(ecoResProduct.RecId);

if (ecoResStorageDimensionGroupProduct.RecId)
{ // mandatory storage dimension group for the product
ecoResStorageDimensionGroupItem.ItemDataAreaId = inventTable.DataAreaId;
ecoResStorageDimensionGroupItem.ItemId = inventTable.ItemId;
ecoResStorageDimensionGroupItem.StorageDimensionGroup = ecoResStorageDimensionGroupProduct.StorageDimensionGroup;
ecoResStorageDimensionGroupItem.insert();
}

if (ecoResTrackingDimensionGroupProduct.RecId)
{ // mandatory tracking dimension group for the product
ecoResTrackingDimensionGroupItem.ItemDataAreaId = inventTable.DataAreaId;
ecoResTrackingDimensionGroupItem.ItemId = inventTable.ItemId;
ecoResTrackingDimensionGroupItem.TrackingDimensionGroup = ecoResTrackingDimensionGroupProduct.TrackingDimensionGroup;
ecoResTrackingDimensionGroupItem.insert();
}
ttsCommit;
info(strfmt("Product successfully released to ‘RAX’ legal entity"));
}
}

how to compare the date field in query | Date query range in AX 2012 | how to add date query range in ax 2012

how to compare the date field in query | Date query range in AX 2012 | how to add date query range in ax 2012
How to set range with Date field with Date value in AX 2012

queryBuildRange.value(strFmt('(ModifiedDate <= %1)', Date2StrXpp(01\01\2000))); // in this example ModifiedDate is query Range field what we are adding. Another example: queryBuildDataSource = query.addDataSource(tablenum(PriceDiscTable)); queryBuildDataSource.addRange(fieldNum(PriceDiscTable,FromDate)).value(strFmt("FromDate<=%1",toDate)); queryBuildDataSource.addRange(fieldNum(PriceDiscTable,ToDate)).value(strFmt("ToDate>=%1",toDate));


Perfect solution is:

public void lookup(FormControl _formControl, str _filterStr)

{

SysTableLookup sysTableLookup;

//Query query = new Query();

//QueryBuildDataSource queryBuildDataSource;

//QueryBuildRange queryBuildRange,queryBuildRangeFrom,queryBuildRangeTo;

//date toDate = today();



PriceDiscTable PriceDiscTable;

QueryRun QueryRun;

Query Query;

QueryBuildDataSource qbds;

QueryBuildRange qbr;



TransDate todaydate;

todaydate = systemDateGet();



super(_formControl, _filterStr);



sysTableLookup = SysTableLookup::newParameters(tablenum(PriceDiscTable), _formControl);



sysTableLookup.addLookupfield(fieldnum(PriceDiscTable, ItemRelation));

sysTableLookup.addLookupfield(fieldnum(PriceDiscTable, relation));

sysTableLookup.addLookupfield(fieldnum(PriceDiscTable, AccountRelation));





Query = new Query();

qbds = Query.addDataSource(tableNum(PriceDiscTable));

qbds.addSortField(fieldNum(PriceDiscTable,todate),SortOrder::Descending);

qbr = SysQuery::findOrCreateRange(qbds,fieldNum(PriceDiscTable,Fromdate));

qbr.value('<='+SysQuery::value(todaydate)); qbr = SysQuery::findOrCreateRange(qbds,fieldNum(PriceDiscTable,todate)); qbr.value( strfmt('((%1 = %2) || (%3 > %4))',fieldStr(PriceDiscTable,ToDate),date2strXPP(datenull()),fieldStr(PriceDiscTable,ToDate),date2StrXPP(todaydate)));



qbr = SysQuery::findOrCreateRange(qbds,fieldNum(PriceDiscTable, AccountRelation));

qbr.value(queryValue(sfcorderguidemaster::find(sfcorderguideitemmaster.Orderguideid).PriceGroup));


qbds.addGroupByField(fieldnum(PriceDiscTable, ItemRelation));

qbds.addGroupByField(fieldnum(PriceDiscTable, ItemCode));

qbds.addGroupByField(fieldnum(PriceDiscTable, AccountRelation));

//add the query to the lookup form

sysTableLookup.parmQuery(query);

// Do the lookup

sysTableLookup.performFormLookup();

}

Ledger Voucher creation Framework and x++ code to create ledger voucher

 Please click her for MS reference file Below is the out of the box example reference and code. SalesInvoiceJournalPostSubBill_Extension->...