Dynamics 365 Finance and Operations
Wednesday, July 29, 2020
Create Movement Journal using X++
Monday, July 27, 2020
How to read csv data from SFTP location through Microsoft Flow and Import into Dynamics 365 Finance and Operations
Create Purchase Order using X++
Sunday, July 26, 2020
Create Transfer Order using X++.
InventTransferTable inventTransferTable;
InventTransferLine inventTransferLine;
InventTransferId inventTransferId;
public void createTransferOrder()
{
ttsBegin;
createHeader();
createLine()
ttsCommit;
}
Sample code to create header of the Transfer Order
public void createHeader()
{
//create the transfer order id.
inventTransferId = InventTransferTable::numberSeq().num();
inventTransferTable.clear();
inventTransferTable.initValue();
inventTransferTable.TransferId = inventTransferId; // assign the transfer order id
inventTransferTable.InventLocationIdFrom = “FromWarehouse”;
inventTransferTable.InventLocationIdTo = “ToWarehouse”;
inventTransferTable.TransferStatus = InventTransferStatus::Created;
inventTransferTable.DlvModeId = “ShipMethod”;
inventTransferTable.ShipDate = “ShipDate”;
inventTransferTable.ReceiveDate = “ReceiveDate”;
inventTransferTable.AutoReservation = NoYes::No;
inventTransferTable.initToAddress();
inventTransferTable.initFromAddress();
inventTransferTable.InventLocationIdTransit = InventLocation::find(“FromWarehouse”).InventLocationIdTransit;
inventTransferTable.validateWrite();
inventTransferTable.insert();
}
public void createLine()
{
InventDim inventDim;
inventDim.clear();
inventTransferLine.clear();
inventDim =
inventTransferLine.inventDim();
inventDim.InventSiteId =
InventLocation::find(inventTransferTable.InventLocationIdFrom).InventSiteId;
inventDim.InventLocationId = inventTransferTable.InventLocationIdFrom;
inventTransferLine.initFromInventTransferTable(inventTransferTable,NoYes::Yes);
inventTransferLine.ItemId = “ItemId”;
inventTransferLine.LineNum = inventTransferLine::lastLineNum(inventTransferTable.TransferId) + 1;
inventTransferLine.initFromInventTable(InventTable::find(“ItemId”));
inventTransferLine.QtyTransfer = “Quantity”;
inventTransferLine.QtyRemainReceive = “Quantity”;
inventTransferLine.QtyRemainShip = “Quantity”;
inventTransferLine.QtyShipNow = 0;
inventTransferLine.QtyReceiveNow = 0;
inventTransferLine.RemainStatus = InventTransferRemainStatus::Shipping;
inventTransferLine.AutoReservation = NoYes::No;
inventTransferLine.InventDimId =
InventDim::findOrCreate(inventDim).inventDimId;;
inventTransferLine.insert();
}
Wednesday, July 31, 2019
Write csv file on Azure Blob
public void WriteCSVFileOnBlob()
{
System.Byte[] byteArray;
System.Text.Encoding encodingUTF8;
str accountName ="<<AccountNameOfBlob>>";
str accountKey ="<<AccountKeyofBlob>>";
str blobName ="<<BlobName>>";
str fileName;
str strRowData;
boolean isColumnsAdded=false;
LogTable logTable;
if(logTable)
{
fileName="inputfilename.csv";
Microsoft.WindowsAzure.Storage.Auth.StorageCredentials storageCredentials = new Microsoft.WindowsAzure.Storage.Auth.StorageCredentials(accountName, accountKey);
Microsoft.WindowsAzure.Storage.CloudStorageAccount storageAccount = new Microsoft.WindowsAzure.Storage.CloudStorageAccount(storageCredentials, true);
var blobcli = storageAccount.CreateCloudBlobClient();
Microsoft.WindowsAzure.Storage.Blob.CloudBlobContainer cont = blobcli.GetContainerReference(blobName);
CloudBlockBlob cloudBlockBlob = cont.GetBlockBlobReference(fileName);
using (Microsoft.WindowsAzure.Storage.Blob.CloudBlobStream x = cloudBlockBlob.OpenWriteAsync().Result)
{
while select logTable where logTable.InputfileName==fileName
{
if(logTable.RecId>0)
{
if(!isColumnsAdded)
{
isColumnsAdded=true;
strRowData= strFmt("%1,%2,%3,%4,%5,%6,%7,%8,%9","ItemCode","DocumentNumber","DocumentReference","WarehouseCode","ProcessName","DateTime","InputFileName","ErrorMessage","\r\n");
encodingUTF8 = System.Text.Encoding::get_UTF8();
byteArray = encodingUTF8.GetBytes(strRowData);
x.Write(byteArray,0,byteArray.Length);
}
strRowData=strFmt("%1,%2,%3,%4,%5,%6,%7,%8,%9",logTable.ItemCode,logTable.DocumentNumber,logTable.DocumentReference,logTable.WarehouseCode,enum2Str(ProcessType),logTable.Datetime,inputfilename,strReplace(logTable.Errormessage,",",";"),"\r\n");
encodingUTF8 = System.Text.Encoding::get_UTF8();
byteArray = encodingUTF8.GetBytes(strRowData);
x.Write(byteArray,0,byteArray.Length);
}
}
if(isColumnsAdded)
{
x.Flush();
x.Close();
}
}
}
}