[FormEventHandler(formStr(InventValueProcess), FormEventType::Initialized)]
public static void InventValueProcess_OnInitialized(xFormRun sender, FormEventArgs e)
{
FormControl invQtyCWTotal_DEV;
InventValueExecutionHistory inventValueExecutionHistoryLocal;
if (sender.args().dataset() == tableNum(InventValueExecutionHistory))
{
inventValueExecutionHistoryLocal = sender.args().record() as InventValueExecutionHistory;
invQtyCWTotal_DEV= sender.design().controlName(formControlStr(InventValueProcess, InventoryQtyCWTotal_INT));
invQtyCWTotal_DEV.visible(inventValueExecutionHistoryLocal.viewInventoryTotal());
}
}
Month: December 2020
D365 How to convert exchange rate
costPrice = CurrencyExchangeHelper::curAmount(costPrice, this.CurrencyCode, purchLine.purchTable().AccountingDate);
However if you are converting a price from the sales table or purchase order to the company currency, using the code below will make use of the Fixed Exchange Rate if it was specified on the Sales/Purchase order.
CurrencyExchangeHelper::mstAmount(_this.SalesPrice,
_this.CurrencyCode,
_this.salestable().createDate(),
_this.salesTable().fixedEuroTriangulation(),
_this.salesTable().fixedExchRate(),
_this.salesTable().fixedExchRateSecondary());
D365 How to convert Unit of measure
public PurchQty convertPurchQtyToSalesUnit_DEV(PurchQty _purchQty,ItemId _itemId,PurchUnit _purchUnit,SalesUnit _salesUnit )
{
PurchQty purchQty;
purchQty = UnitOfMeasureConverter::convert(_purchQty,
UnitOfMeasure::unitOfMeasureIdBySymbol(_purchUnit),
UnitOfMeasure::unitOfMeasureIdBySymbol(_salesUnit),
NoYes::Yes,
InventTable::itemProduct(_itemId),
NoYes::Yes);
return purchQty;
}
D365 How to create a new Free Text Invoice design
- Duplicate the FreeTextInvoice report and call it FreeTextInvoice_DEV
- Extend the PrintMgmtDelegatesHandler class and name the extension class PrintMgmtDelegatesHandler_DEV_Extension
<code>
[ExtensionOf(classstr(PrintMgmtDelegatesHandler))]
final class PrintMgmtDelegatesHandler_DEV_Extension
{
protected static PrintMgmtReportFormatName getDefaultReportFormat(PrintMgmtDocumentType _docType)
{
PrintMgmtReportFormatName formatName = next getDefaultReportFormat(_docType);
switch (_docType)
{
// design options available for PrintMgmtDocumentType::VendPaymAdvice
case PrintMgmtDocumentType::VendPaymAdvice:
formatName = ssrsReportStr(VendOutRemittAdviceEFT_DEV, Report);
break;
// design options available for PrintMgmtDocumentType::CustAccountStatement
//case PrintMgmtDocumentType::CustAccountStatement:
// formatName = ssrsReportStr(CustAccountStatementExtModern_DEV, Report);
// break;
// design options available for PrintMgmtDocumentType::SalesFreeTextInvoice
case PrintMgmtDocumentType::SalesFreeTextInvoice:
formatName = ssrsReportStr(FreeTextInvoiceModern_DEV, Report);
break;
}
return formatName;
}
}
</code>
3. Extend PrintMgmtReportFormatPopulator and rename to PrintMgmtReportFormatPopulator_DEV_Extension.
[ExtensionOf(classStr(PrintMgmtReportFormatPopulator))]
final class PrintMgmtReportFormatPopulator_DEV_Extension
{
#PrintMgmtSetup
public void populate(boolean _deleteAll, boolean _showConfirmation)
{
// populate the standard application solutions
next populate(_deleteAll, _showConfirmation);
// design options available for PrintMgmtDocumentType::VendPaymAdvice
this.addOther(PrintMgmtDocumentType::VendPaymAdvice,
ssrsReportStr(VendOutRemittAdviceEFT_DEV, Report),
ssrsReportStr(VendOutRemittAdviceEFT_DEV, Report),
#NoCountryRegionId);
// design options available for PrintMgmtDocumentType::CustAccountStatement
//this.addOther(PrintMgmtDocumentType::CustAccountStatement,
// ssrsReportStr(CustAccountStatementExtModern_DEV, Report),
// ssrsReportStr(CustAccountStatementExtModern_DEV, Report),
// #NoCountryRegionId);
// design options available for PrintMgmtDocumentType::SalesFreeTextInvoice
this.addOther(PrintMgmtDocumentType::SalesFreeTextInvoice,
ssrsReportStr(FreeTextInvoiceModern_DEV, Report),
ssrsReportStr(FreeTextInvoiceModern_DEV, Report),
#NoCountryRegionId);
}
}
D365 SSRS sample code – Rename “Invoice” to “Tax invoice”
Add the code below to the code section of the report:
Public Function ChangeTitle(ByVal s As String) As String
Dim strBuilder As New System.Text.StringBuilder(s)
If s.Contains("Invoice") Then
strBuilder.Replace("Invoice", "Tax Invoice")
Return strBuilder.ToString()
Elseif s.Contains("invoice")
strBuilder.Replace("invoice", "Tax Invoice")
Return strBuilder.ToString()
Else :
Return s
End If
End Function
Use expression below on the textbox:
=code.ChangeTitle(Parameters!DocumentTitle.Value)
D365 SSRS sample code – Displaying page number on the body of the report
By default, SSRS does not allow you to display global variables such as page number on the body of the report. They can only be used in the header or footer section of the report.
If you want to display the page on the body of the report, you can use this code. Add the code below to the code section of the SSRS report
Function PageNumber() As String
Return Me.Report.Globals!PageNumber
End Function
Function TotalPages() As String
Return Me.Report.Globals!TotalPages
End Function
D365 – How to deploy reports using Powershell
- Open Windows Powershell
- Run this script to deploy all reports
K:\AosService\PackagesLocalDirectory\Plugins\AxReportVmRoleStartupTask\DeployAllReportsToSSRS.ps1 -PackageInstallLocation “K:\AosService\PackagesLocalDirectory”
D365 – How to back up a database in UAT and restore to a Tier 1 DEV environment
- Go to the UAT and click on Move Database > Export Database. This will export the database into Asset Library.
2. Once export is completed, log on to the DEV server and download the bacpac file from the Asset Library into the local drive.
3. Run this command in the command prompt
cd C:\Program Files (x86)\Microsoft SQL Server\140\DAC\bin
SqlPackage.exe /a:import /sf:C:\Temp\UATbackup.bacpac /tsn:localhost /tdn:AxDBUAT /p:CommandTimeout=1200
4. While that is running, backup the database in DEV.
5. Rename the AxDB database to AxDB_old then rename AxDBUAT database to AxDB.
6. Synchronize DB