Thursday, June 1, 2023

Import sql database restore bacpac format using Sqlpackage.exe in DEV VM

SqlPackage.exe /Action:Import /TargetServerName:"localhost" /TargetDatabaseName:"Testbackup" /TargetTrustServerCertificate:True /SourceFile:"C:\Temp\Testbackup.bacpac" /p:CommandTimeout=6200

delete from using query run class in D365FO

/// <summary>
/// Method that deletes records in any given table based on the value.
/// </summary>
/// <param name = "_tableToClean">
/// The ID of the table in which records are deleted.
/// </param>
/// <returns>
/// The number of records deleted from the table.
/// </returns>
protected NumberOfRecords cleanUpTableRecords(TableId   _tableToClean)
{
	Query                   query;
	QueryBuildDataSource    queryBuildDataSource;
	QueryBuildRange         queryBuildRange;

	query = new Query();
	queryBuildDataSource = SysQuery::findOrCreateDataSource(query, _tableToClean);

	return int642int(Query::delete_from(query, true, true, true));
}

Get D365FO label translation in specific language at runtime using X++

Label label = new Label(_custInvoiceJour.LanguageId ? _custInvoiceJour.LanguageId : infolog.language());
str txt = strFmt(label.extractString(literalStr("@Currency")));

Rename AX database after restore

USE master
GO
ALTER DATABASE AxDB
SET SINGLE_USER
WITH ROLLBACK IMMEDIATE
GO
ALTER DATABASE AxDB
Modify Name = AxDB_Contoso
GO
ALTER DATABASE AxDB_Contoso
SET MULTI_USER
GO

Table browser URL in D365FO

Critical Thinking icon icon by Icons8