This blog is for Dynamics AX (AXAPTA) Developers,this will help you for your development issues. This site contains some Microsoft Dynamics AX X++ Codes for use in your day to day use.
21 December 2025
Customer inbound custom service in D365 F&O with X++
How to download the multiple document attchments in D365 F&O Using X++
The below code is to download the attachments which are attached in Vendor Invoice journals
AP->Inquiries and reports->Invoice-> Invoice Journal
21 November 2025
DB restore production DB to DEV environment in D365 FO using Bacpac file
https://www.linkedin.com/pulse/restore-production-database-dev-environment-d365fo-using-abbas-tfwbe
SQLPackage link : https://www.linkedin.com/redir/redirect?url=https%3A%2F%2Fgo%2Emicrosoft%2Ecom%2Ffwlink%2F%3Flinkid%3D2261576&urlhash=8Q0l&trk=article-ssr-frontend-pulse_little-text-block
Step1. Need to download SQL package
Stop all the required services
Rename the AXDB to AXDB Old
Run the command to connect to package extracted path
Then Run the below command. To import
==
SqlPackage.exe /a:import /sf:C:\SQLPackage\carlsbergbalkanchinabackup.bacpac /tsn:vm-WE-MD09-d-1 /tdn:AxDB /p:CommandTimeout=200000 /TargetEncryptConnection:False
tsn (target server name) – The name of the SQL Server to import into.
tdn (target database name) – The name of the database to import into. The database should not already exist.
sf (source file) – The path and name of the file to import from.
/p:CommandTimeout=200000 seconds approximately 55 hours timeout for command
/TargetEncryptConnectionLFalse this is the updated script which will keep us away from certificate errors
After DB import run the below script
CREATE USER axdeployuser FROM LOGIN axdeployuser
EXEC sp_addrolemember 'db_owner', 'axdeployuser'
CREATE USER axdbadmin FROM LOGIN axdbadmin
EXEC sp_addrolemember 'db_owner', 'axdbadmin'
CREATE USER axmrruntimeuser FROM LOGIN axmrruntimeuser
EXEC sp_addrolemember 'db_datareader', 'axmrruntimeuser'
EXEC sp_addrolemember 'db_datawriter', 'axmrruntimeuser'
CREATE USER axretaildatasyncuser FROM LOGIN axretaildatasyncuser
CREATE USER axretailruntimeuser FROM LOGIN axretailruntimeuser
CREATE USER axdeployextuser FROM LOGIN axdeployextuser
CREATE USER [NT AUTHORITY\NETWORK SERVICE] FROM LOGIN [NT AUTHORITY\NETWORK SERVICE]
EXEC sp_addrolemember 'db_owner', 'NT AUTHORITY\NETWORK SERVICE'
UPDATE T1
SET T1.storageproviderid = 0
, T1.accessinformation = ''
, T1.modifiedby = 'Admin'
, T1.modifieddatetime = getdate()
FROM docuvalue T1
WHERE T1.storageproviderid = 1 --Azure storage
DROP PROCEDURE IF EXISTS SP_ConfigureTablesForChangeTracking
DROP PROCEDURE IF EXISTS SP_ConfigureTablesForChangeTracking_V2
GO
-- Begin Refresh Retail FullText Catalogs
DECLARE @RFTXNAME NVARCHAR(MAX);
DECLARE @RFTXSQL NVARCHAR(MAX);
DECLARE retail_ftx CURSOR FOR
SELECT OBJECT_SCHEMA_NAME(object_id) + '.' + OBJECT_NAME(object_id) fullname FROM SYS.FULLTEXT_INDEXES
WHERE FULLTEXT_CATALOG_ID = (SELECT TOP 1 FULLTEXT_CATALOG_ID FROM SYS.FULLTEXT_CATALOGS WHERE NAME = 'COMMERCEFULLTEXTCATALOG');
OPEN retail_ftx;
FETCH NEXT FROM retail_ftx INTO @RFTXNAME;
BEGIN TRY
WHILE @@FETCH_STATUS = 0
BEGIN
PRINT 'Refreshing Full Text Index ' + @RFTXNAME;
EXEC SP_FULLTEXT_TABLE @RFTXNAME, 'activate';
SET @RFTXSQL = 'ALTER FULLTEXT INDEX ON ' + @RFTXNAME + ' START FULL POPULATION';
EXEC SP_EXECUTESQL @RFTXSQL;
FETCH NEXT FROM retail_ftx INTO @RFTXNAME;
END
END TRY
BEGIN CATCH
PRINT error_message()
END CATCH
CLOSE retail_ftx;
DEALLOCATE retail_ftx;
-- End Refresh Retail FullText Catalogs
--Begin create retail channel database record--
declare @ExpectedDatabaseName nvarchar(64) = 'Default';
declare @DefaultDataGroupRecId BIGINT;
declare @ExpectedDatabaseRecId BIGINT;
IF NOT EXISTS (select 1 from RETAILCONNDATABASEPROFILE where NAME = @ExpectedDatabaseName)
BEGIN
select @DefaultDataGroupRecId = RECID from RETAILCDXDATAGROUP where NAME = 'Default';
insert into RETAILCONNDATABASEPROFILE (DATAGROUP, NAME, CONNECTIONSTRING, DATASTORETYPE)
values (@DefaultDataGroupRecId, @ExpectedDatabaseName, NULL, 0);
select @ExpectedDatabaseRecId = RECID from RETAILCONNDATABASEPROFILE where NAME = @ExpectedDatabaseName;
insert into RETAILCDXDATASTORECHANNEL (CHANNEL, DATABASEPROFILE)
select RCT.RECID, @ExpectedDatabaseRecId from RETAILCHANNELTABLE RCT
inner join RETAILCHANNELTABLEEXT RCTEX on RCTEX.CHANNEL = RCT.RECID
update RETAILCHANNELTABLEEXT set LIVECHANNELDATABASE = @ExpectedDatabaseRecId where LIVECHANNELDATABASE = 0
END;
---------------
Restart the required services.
Refresh models and build the Models
24 August 2025
How to add the Display method in the form level in D365 F&O
The below examle is to add the form -Data source level adding display method and assigning to form design control.
25 April 2025
AXmodel file import in D365 F&O
ModelUtil.exe -import -metadatastorepath=k:\aosservice\packageslocaldirectory -file=C:\Temp\DEST.axmodel
10 April 2025
X++ code to get the time and add and substract using the current date time in D365 F&O
utcdatetime dateTime = DateTimeUtil::getSystemDateTime();//DateTimeUtil::utcNow();
utcdatetime newDateTime = DateTimeUtil::addMinutes(dateTime, -20);
Info(strFmt("Current time: %1 redueced Time: %2 ",dateTime,newDateTime));
09 April 2025
X++ code to create new user in D365 F&O
public void createUser(UserId _userId,Name _userName)
{
UserInfo userInfo;
SecurityUserRole userRole,userRoleToSave;
SecurityRole securityRole;
// Step 1: Create new User Info record
ttsBegin;
userInfo.id = _userId;
userInfo.Name = _userName;
userInfo.networkAlias = Xine_UserAcessTable.Email;
userInfo.networkDomain = Xine_UserAcessTable.NetworkDomain;
userInfo.ObjectId = Xine_UserAcessTable.TelemetryId;
userInfo.enable = Xine_UserAcessTable.Enabled;
userInfo.insert(); // Save the user info record
info(strFmt('User created: %1', userInfo.id));
select securityRole
where securityRole.Name == "System user";
select forupdate userRoleToSave
where userRoleToSave.User == _userId &&
userRoleToSave.SecurityRole == securityRole.recId;
if ( userRoleToSave.recId)
{
userRoleToSave.AssignmentMode = RoleAssignmentMode::Manual;
userRoleToSave.AssignmentStatus = RoleAssignmentStatus::Enabled;
userRoleToSave.update();
}
else
{
userRole.User = _userId;
userRole.SecurityRole = securityRole.recId; // Set the role of the user (System User role is used here as an example)
userRole.AssignmentMode = RoleAssignmentMode::Manual;
userRole.AssignmentStatus = RoleAssignmentStatus::Enabled;
userRole.insert(); // Save user role
info(strFmt('Role assigned to user: %1', userRole.SecurityRole));
}
// Commit the transaction
ttsCommit;
}
Customer inbound custom service in D365 F&O with X++
[DataContractAttribute] class GOD_CustomerCreateContract { str accountNum; // Optional; if blank, a number sequenc...
-
static void createForm(Args _args) { Args args; Form form; FormRun formRun; FormBuildDesign formBuildDesign; FormB...
-
Please click here to access Custom Workflow step by step process:
-
1. In classDeclaration extend SrsReportDataProviderPreProcess instead of SrsReportDataProviderBase 2. Temp table properties should b...