• Skip to main content
  • Skip to primary sidebar
  • Home
  • About
  • Recommended Readings
    • 2022 Book Reading
    • 2023 Recommended Readings
    • Book Reading 2024
    • Book Reading 2025
    • Book Reading 2026
  • Supply Chain Management Guide
  • PKM
  • Microsoft Excel
  • Microsoft Copilot in Office 365
  • Public Wiki Page

Ali Raza Zaidi

A practitioner’s musings on Dynamics 365 Finance and Operations

alirazazaidi

Performance-First Coding Best Practices for D365 Finance & Operations

September 19, 2026 by alirazazaidi

Writing code that works is only the first step in Dynamics 365 Finance & Operations development. In enterprise implementations, customizations must also be efficient, maintainable, scalable, and aligned with D365 F&O best practices.

Some performance-oriented practices may initially appear to require additional development effort. However, the objective should not be to write the shortest possible code. The objective is to write code that performs efficiently when processing real production volumes.

This article focuses on two areas that frequently affect code quality and performance:

  • Variable declarations and scope
  • Database access using X++ select statements

1. Variable Declaration and Scope

Older Dynamics AX development commonly followed the pattern of declaring most variables at the beginning of a method. In modern X++ development, variables should generally be declared closer to where they are actually required.

Keep Variables Close to Their Usage

Avoid declaring every variable at the top of a method when it is only required much later.

For example, instead of:

public void processOrder()
{
    SalesTable salesTable;
    SalesLine salesLine;
    AmountCur totalAmount;
    boolean isValid;

    // Other processing...

    totalAmount = salesTable.SalesBalance;
}

prefer declaring variables where they become relevant:

public void processOrder()
{
    // Other processing...

    AmountCur totalAmount = salesTable.SalesBalance;
}

This makes the code easier to read and reduces unnecessary variable scope.

Limit the Scope of Variables

A variable should exist only within the scope where it is required.

Smaller scopes provide several benefits:

  • Improved readability
  • Reduced accidental reuse
  • Easier debugging
  • Clearer ownership of values
  • Better maintainability

This applies to primitive types, extended data types, enums, classes, and table buffers.

Declare Table Buffers Only When Required

Table buffers should not be created simply because they might be needed later.

Declare them when they are actually required and, where appropriate, reuse an existing buffer rather than introducing unnecessary additional buffers.

Instead of maintaining multiple buffers for the same purpose, first consider whether the existing buffer can safely be reused.

Be Careful with Variables Inside Loops

If the same variable or object is required repeatedly during loop processing, consider whether it should be declared outside the loop.

For example:

AmountCur lineAmount;

while select SalesLine
    where SalesLine.SalesId == salesTable.SalesId
{
    lineAmount = SalesLine.LineAmount;

    // Process amount
}

The important point is not simply “inside versus outside” the loop. The declaration should reflect the required scope and avoid unnecessary repeated initialization of objects or expensive resources.

Remove Unused Variables

Unused declarations should always be removed.

They increase code noise, make reviews more difficult, and can create confusion about whether a variable has a purpose that is no longer obvious.

A clean method should contain only the variables required by its current implementation.


2. Optimize Database Access

Database access is one of the most important performance considerations in D365 Finance & Operations.

Poorly designed queries may work perfectly with a small development database but become expensive when executed against millions of production records.

The basic principle is simple:

Retrieve only the data you need, and minimize unnecessary database round trips.

Select Only the Required Fields

Avoid retrieving an entire record when only a small number of fields are required.

Instead of:

select firstonly custTable
    where custTable.AccountNum == _accountNum;

consider selecting only the required fields:

select firstonly AccountNum, Name
    from custTable
    where custTable.AccountNum == _accountNum;

This makes the intention of the query clearer and avoids retrieving unnecessary data.

This practice becomes particularly valuable for large tables and performance-sensitive processing.


Avoid Unnecessary find() Calls

Standard table find() methods are convenient and have legitimate uses. However, they should not automatically be the default choice in performance-sensitive code.

For example:

custTable = CustTable::find(_accountNum);

If the customization requires only one or two fields, an explicit query may communicate the requirement more clearly:

select firstonly AccountNum, Name
    from custTable
    where custTable.AccountNum == _accountNum;

The important consideration is understanding what the underlying method does and whether it retrieves or processes more information than the customization actually requires.


3. Reduce Database Round Trips with Joins

A common performance problem is executing multiple database queries when the required information can be retrieved through a single joined query.

For example, code may first retrieve a sales order and then execute another query to retrieve related customer information.

Instead, consider combining the operations:

select firstonly SalesId, CustAccount
    from salesTable
    join AccountNum, Name
        from custTable
    where salesTable.SalesId == _salesId
       && custTable.AccountNum == salesTable.CustAccount;

The general principle is:

Prefer one well-designed query over several sequential database calls when the data can naturally be retrieved together.

Reducing database round trips becomes increasingly important in batch processing, integrations, reports, and high-volume transactions.


4. Use exists join When You Only Need to Check Existence

Sometimes a related table is required only to determine whether a matching record exists.

In such cases, there is no reason to retrieve fields from that table.

Instead of retrieving unnecessary related data, use an exists join:

select firstonly AccountNum
    from custTable
    exists join salesTable
    where salesTable.CustAccount == custTable.AccountNum
       && salesTable.SalesStatus == SalesStatus::Backorder;

An exists join is particularly useful when:

  • No fields are required from the related table.
  • The related table is used only as a filter.
  • You only need to confirm that a matching record exists.

Choose the join type based on the data requirement rather than automatically using join or outer join.


5. Understand Table Methods Before Calling Them

Table methods can improve encapsulation and reuse, so they should not be avoided simply because they are methods.

However, developers should understand the cost of the methods they call.

A method that appears simple may internally:

  • Execute additional SQL queries
  • Call another table’s find() method
  • Perform calculations
  • Traverse related records
  • Execute business logic that is unnecessary for the current scenario

This becomes especially important when a method is called repeatedly inside a loop.

For example:

while select salesLine
{
    value = salesLine.someMethod();
}

If someMethod() performs a database query, processing 10,000 sales lines could potentially generate thousands of additional database operations.

Before using such methods in performance-critical processing, review their implementation.

If the method contains important business logic, reuse it appropriately. If it merely retrieves simple data that can efficiently be included in the main query, consider retrieving that information as part of the original query.


6. Use Guard Clauses Before Expensive Operations

Validation should happen as early as possible.

Before executing a database query, determine whether the input already tells you that processing should stop.

Instead of:

select firstonly salesTable
    where salesTable.SalesId == _salesId;

if (!_salesId)
{
    return;
}

validate first:

if (!_salesId)
{
    return;
}

select firstonly SalesId
    from salesTable
    where salesTable.SalesId == _salesId;

This pattern is commonly known as a guard clause.

Guard clauses are useful for checking:

  • Missing parameters
  • Invalid enum values
  • Empty record identifiers
  • Unsupported statuses
  • Disabled functionality
  • Conditions that make further processing unnecessary

The principle is straightforward:

Do not query the database when you already know that no processing is required.


7. Be Especially Careful with Queries Inside Loops

One of the most important areas to review in X++ code is database access inside loops.

Consider:

while select salesLine
{
    custTable = CustTable::find(salesLine.CustAccount);

    // Processing
}

If thousands of records are processed, this pattern may result in a large number of database calls.

Where possible, redesign the query using joins, set-based processing, caching, or preloaded data.

When reviewing code, always pay particular attention to:

while select
for
do while
while

and check whether database queries or expensive methods are being executed repeatedly inside them.


8. Performance Should Be Considered During Development

Performance optimization should not be treated only as a final activity after development is complete.

During implementation and code review, developers should continuously ask:

  • Am I retrieving fields that I do not need?
  • Can multiple queries be combined?
  • Is this query running inside a loop?
  • Does this method execute another database query internally?
  • Can an exists join be used?
  • Can processing stop earlier?
  • Is there a set-based alternative?
  • Will this approach still perform well with production-scale data?

A customization that works with 100 records may behave very differently with 1 million records.

Final Thoughts

Good D365 F&O development is not just about producing technically correct X++ code. It is about producing code that remains reliable and efficient as transaction volumes grow.

The key principles are:

  1. Keep variable scope small and intentional.
  2. Remove unused declarations and unnecessary buffers.
  3. Retrieve only the fields you actually need.
  4. Reduce database round trips by using appropriate joins.
  5. Use exists join when related records are required only for filtering.
  6. Understand what table methods do before using them repeatedly.
  7. Validate conditions early with guard clauses.
  8. Avoid repeated database access inside loops wherever possible.
  9. Design and review customizations with production data volumes in mind.

In D365 Finance & Operations, a few milliseconds of unnecessary processing may appear insignificant during development. When the same logic runs thousands or millions of times in production, however, those small inefficiencies can become significant performance problems.

Performance should therefore be part of the design—not an afterthought.

D365 Finance and Operations Technical Training Day 6, 7 and 8

August 9, 2026 by alirazazaidi

While writing this post the couplet of Ghalib came into my mind

بازیچۂ اطفال ہے دنیا مرے آگے
ہوتا ہے شب و روز تماشا مرے آگے

ہوتا ہے نہاں گرد میں صحرا مرے ہوتے
گھستا ہے جبیں خاک پہ دریا مرے آگے

مت پوچھ کہ کیا حال ہے میرا ترے پیچھے
تو دیکھ کہ کیا رنگ ہے تیرا مرے آگے

ایماں مجھے روکے ہے، جو کھینچے ہے مجھے کفر
کعبہ مرے پیچھے ہے، کلیسا مرے آگے

So what is contribution

D365 Technical Training Day 2 to Day 5

July 22, 2026 by alirazazaidi

Let’s revisit the fundamentals! I’m planning to create a 28-video technical training series on Microsoft Dynamics 365 Finance & Operations (D365 F&O). The goal is to build a strong foundation for beginners and aspiring D365 developers by covering core technical concepts step by step.

🎉 The first 4 videos are now completed and available on YouTube!

Current Playlist:

  • ✅ Day 2 – Download and Configure the D365 F&O OneBox VM
  • ✅ Day 3 – Visual Studio, Models & Packages
  • ✅ Day 3 – Primitive Data Types, Extended Data Types (EDTs) & Base Enums
  • ✅ Day 4 – D365 Technical Training Day 5 How to create table in D365 Finance and operations

I’ll continue uploading the remaining videos regularly, covering topics such as tables, forms, classes, queries, data entities, integrations, debugging, best practices, and much more.

If you’re starting your journey as a D365 F&O Technical Consultant or X++ Developer, this series is designed to help you learn from the ground up.

Don’t forget to Like, Share, and Subscribe to stay updated with every new lesson!

D365 Technical Training Day 2 : How to download and configure One Box VM on your laptop

D365 Techical Training Day 3 | Visual Studio, Model, packages

D365 F&O Technical Training – Day 4 | Primitive Data Types, Extended Data Types (EDTs) & Base Enums

D365 Technical Training Day 5 How to create table in D365 Finance and operations

Embedding Websites in Microsoft Dynamics 365 Finance & Operations (D365FO)

July 1, 2026 by alirazazaidi

esterday, I worked on a small proof of concept (POC) to embed an external web page inside Microsoft Dynamics 365 Finance & Operations.

Initially, I thought the solution would require using an iframe. However, after some research, I discovered that WebsiteHostControl provides a much cleaner and more suitable approach.

The implementation is straightforward:

  1. Create a custom form.
  2. Apply the appropriate form pattern.
  3. Add a Tab control with a Tab Page.
  4. Add a Group control inside the Tab Page.
  5. Set the Group control’s Width Mode and Height Mode properties to Size to Available.

From there, you can add the WebsiteHostControl to the group and configure it to display the required external web page within the D365 Finance & Operations form.

Overall, it turned out to be much simpler than I initially expected, and WebsiteHostControl is the recommended approach for hosting external web content inside a D365 F&O form.

Then add a website host
Set its properties auto declaration to true
and Height mode and Width Mode to size to available

Inside form Initialize method just give url

public class FormTest extends FormRun
{
    /// <summary>
    ///
    /// </summary>
    public void init()
    {
        super();

        WebsiteHostControl1.url("https://www.tech.alirazazaidi.com");
    }

}



On running the form it will look like this

Thriving in the Age of AI: Strengthening Human Skills

June 17, 2026 by alirazazaidi

To thrive in the age of AI, we need to learn how to work effectively with both humans and machines.

Most importantly, we must focus on the human side of work.

According to one estimate, success at work has traditionally been 75% communication and relationship-building, and only 25% technical expertise.

With the rise of AI, that balance is shifting even further. In many roles, human skills now account for 85% of success, while technical skills make up only 15%.

To succeed in this new era, we must adapt to the changes brought by AI and strengthen our soft skills.

The challenge is that while technology has made communication easier, it has not necessarily improved connection.

AI is growing rapidly, and it is here to stay. Yet our connections with other human beings are becoming more fragile. We are losing the ability to build meaningful relationships.

Connection is a skill. Like any skill, if we do not practice it, it weakens over time.

So, how do we navigate disagreements and work better with others?

Here are four principles to improve your human skills in the age of AI.

1. Seek Understanding, Not Just Agreement

Imagine you are participating in a debate competition. Based on a coin toss, you might have to argue either for or against a topic.

Life works the same way.

When someone challenges your point of view, try to understand their perspective rather than immediately defending your own.

The goal is not to agree with every opinion. The goal is to understand it.

We are often taught to win arguments and convince others. Instead, we should focus on understanding how others see the world.

When we do that, we become more persuasive, more empathetic, and more effective collaborators.

Approach conversations with curiosity rather than judgment.

AI can help with this. Whenever you disagree with someone, ask AI to explain the other person’s perspective. It can help you see the issue from different angles.

2. Expand the Pie

Think beyond win-or-lose situations. Look for win-win outcomes.

I once negotiated with a shopkeeper, and we could not agree on the price. Instead of continuing to bargain, I asked myself, “What else is possible?”

I offered to recommend his shop to my friends if he could lower the price. He agreed.

I bought the product at a fair price, and later I brought my friends to his store.

We both benefited.

Too often, we approach life with a win-lose mindset. But most successful relationships are built on mutual value.

Expanding the pie means creating opportunities where everyone gains.

This mindset transforms competition into collaboration.

Instead of asking, “How can I win?” ask, “How can we create more value together?”

3. Diversify Your Circles

Surround yourself with people who think differently from you.

Build relationships with people from different backgrounds, cultures, professions, beliefs, and experiences.

Diverse teams create stronger ideas and better solutions because they bring multiple perspectives to the table.

There is a saying: “Show me your friends, and I’ll show you your future.”

Actively seek new connections, especially with people outside your usual circles.

Find common ground despite your differences. Those shared interests become the foundation for meaningful relationships.

4. Show That You Care

People remember how you make them feel.

Offer a helping hand. Listen carefully. Support others, even when it requires extra effort.

If someone is preparing a presentation, help them. Understand their goals and encourage their ambitions.

Show genuine interest in their success.

At the end of the day, people want to feel heard, understood, and appreciated.

When people feel valued, teams thrive. When they feel ignored, teams break apart.

Reach out to someone. Check in on them. Make time to connect.

In the age of AI, technical skills will continue to evolve, but human connection will always matter.

Build the muscles that allow you to work effectively with both people and machines.

Simple formula for better prompt engineering in Any AI tool

June 14, 2026 by alirazazaidi

Act as a [Role].
Your task is to [Task].

Context: [Background, audience, goals, and constraints]

Output Requirements: [Format, tone, length, and specific instructions]


1. Role

Tell the AI who it should act as.

Examples:

  • Act as a Senior Software Architect.
  • Act as a Chief Financial Officer (CFO).
  • Act as a Digital Marketing Expert.
  • Act as a Dynamics 365 Finance & Operations Solution Architect.

The more specific the role, the better the AI can tailor its response.


2. Task

Clearly describe what you want the AI to do.

Examples:

  • Write an article.
  • Create a project plan.
  • Analyze a business problem.
  • Compare different solutions.
  • Design a system architecture.

Example Task:

Write a detailed article explaining why Dynamics 365 Finance & Operations is an excellent ERP solution for inventory management and financial operations.


3. Context

Provide the necessary background information.

Include:

  • Target audience
  • Business goals
  • Industry
  • Constraints
  • Relevant assumptions

Example Context:

The audience consists of CFOs, Financial Advisors, CTOs, and CEOs. The goal is to help decision-makers understand how Dynamics 365 Finance & Operations improves inventory visibility, financial control, operational efficiency, and business scalability.


4. Output Requirements

Specify exactly how you want the response presented.

Include:

  • Format
  • Tone
  • Length
  • Structure
  • Special requirements

Example Output Requirements:

  • Write approximately 3,000 words.
  • Use a professional and executive-friendly tone.
  • Include an executive summary.
  • Explain key business benefits.
  • Compare traditional ERP systems with Dynamics 365 Finance & Operations.
  • Present pros and cons in a table.
  • Use bullet points where appropriate.
  • Include a conclusion with recommendations for business leaders.

Complete Example Prompt

Act as a Senior Dynamics 365 Finance & Operations Solution Architect.

Your task is to write a comprehensive article explaining why Dynamics 365 Finance & Operations is one of the best ERP solutions for inventory management and financial operations.

Context:
The target audience includes CFOs, Financial Advisors, CTOs, and CEOs. The article should help business leaders understand the strategic, operational, and financial benefits of implementing Dynamics 365 Finance & Operations.

Output Requirements:

  • Write approximately 3,000 words.
  • Use a professional yet easy-to-understand tone.
  • Include an executive summary.
  • Explain inventory management capabilities.
  • Explain financial management capabilities.
  • Compare Dynamics 365 Finance & Operations with traditional ERP systems.
  • Include a pros and cons table.
  • Use headings, subheadings, and bullet points.
  • End with practical recommendations for executives evaluating ERP solutions.

A simple way to remember this framework is:

R-T-C-O = Role → Task → Context → Output

Most weak prompts miss one or more of these four elements. The more clearly you define them, the better the AI’s response will be.

GPTs that Every D365 Finance and Operation Consultant Must use

April 17, 2026 by alirazazaidi

There are many GPTs available that are specifically trained to help answer different types of questions.

Some of these GPTs are focused on Dynamics 365 Finance & Operations, helping with areas like X++, functional processes, troubleshooting, and solution design. For example, GPTs like D365F&O-GPT are built to act as experts for Finance & Operations queries.

You can also build and share your own GPTs, but this requires the Pro version of ChatGPT.

These GPTs become more useful over time as people continue to use and interact with them. In fact, similar AI assistants are being developed specifically for the D365 ecosystem to provide faster and more reliable guidance by combining documentation, best practices, and real-world experience.

Personally, I use these four GPTs related to Dynamics 365 Finance & Operations. You can search for them, try them out, and explore others as well—new ones are being added by the community every day.

  • X++ Dev Helper for Dynamics
  • Dynamics 365 Architect
  • Dynamics 365FO Expert
  • Dr Dynamics – D365 F&O Architect

Lets do a better prompt

April 14, 2026 by alirazazaidi

I am using AI since 2023. Many times I think, I could deliver better if I had these tools couple of years back.

But second time is now.

Here are my notes for Prompot Engineering. And why it is called engineering.

A prompt typically has three main parts:

  1. Top (Role & Output Expectation)
    Define the role you want the AI to take and specify the type of output you expect.
  2. Middle (Task & Context)
    Clearly describe the task and provide the necessary background or context.
  3. Bottom (Format & Constraints)
    Specify how the response should be structured (e.g., bullet points, paragraphs) and include any constraints such as word limits or tone.

Why is it called Prompt Engineering?
Because it is a structured approach to problem-solving. You are designing inputs in a deliberate way to get precise and useful outputs.


Types of Prompts

  1. Zero-Shot Prompting
    No examples are provided. The model relies entirely on the instructions.
  2. Few-Shot Prompting
    Includes examples and reasoning to guide the model toward the desired output.

request for Quotation process in D365 Finance and Operations

February 14, 2026 by alirazazaidi

Daily vs Periodic Ledger Journal Names in D365 Finance

February 6, 2026 by alirazazaidi

While working with ledger transactions in the General Journal in Microsoft Dynamics 365 Finance, two types of Ledger Journal Names are most commonly used: Daily and Periodic. Other journal names exist, but they are usually specific to certain business scenarios.

There are no strict or hard-and-fast rules for using Daily or Periodic journal names. However, in practice, they are typically used in the following way:

  • Daily journals are used for day-to-day transactional postings, such as routine adjustments or operational entries that occur regularly during the accounting period.
  • Periodic journals are used at the end of an accounting period for adjustments and closing activities, such as accruals, allocations, depreciation, and other period-end corrections.

In simple terms:

Daily journals support regular business operations,
Periodic journals ensure financial accuracy at period close.

This practical distinction helps organizations keep operational postings separate from period-end accounting activities, making audits, reviews, and month-end closing processes easier to manage.

Next Page »

Primary Sidebar

About

I am Dynamics AX/365 Finance and Operations consultant with years of implementation experience. I has helped several businesses implement and succeed with Dynamics AX/365 Finance and Operations. The goal of this website is to share insights, tips, and tricks to help end users and IT professionals.

Legal

Content published on this website are opinions, insights, tips, and tricks we have gained from years of Dynamics consulting and may not represent the opinions or views of any current or past employer. Any changes to an ERP system should be thoroughly tested before implementation.

Categories

  • Accounts Payable (2)
  • Advance Warehouse (2)
  • AI (3)
  • Asset Management (3)
  • Azure Functions (1)
  • Books (6)
  • Certification Guide (3)
  • ChatGPT (3)
  • Claude (1)
  • Customization Tips for D365 for Finance and Operations (65)
  • D365OF (60)
  • Data Management (1)
  • database restore (1)
  • Dynamics 365 (59)
  • Dynamics 365 for finance and operations (139)
  • Dynamics 365 for Operations (176)
  • Dynamics AX (AX 7) (134)
  • Dynamics AX 2012 (274)
  • Dynamics Ax 2012 Forms (13)
  • Dynamics Ax 2012 functional side (16)
  • Dynamics Ax 2012 Reporting SSRS Reports. (31)
  • Dynamics Ax 2012 Technical Side (52)
  • Dynamics Ax 7 (65)
  • Exam MB-330: Microsoft Dynamics 365 Supply Chain Management (7)
  • Excel Addin (1)
  • Favorites (12)
  • Financial Modules (6)
  • Functional (8)
  • General Journal (1)
  • Implementations (1)
  • Ledger (1)
  • Lifecycle Services (2)
  • Logseq (4)
  • Management Reporter (1)
  • Microsoft Excel (4)
  • MS Dynamics Ax 7 (64)
  • MVP summit (1)
  • MVP summit 2016 (1)
  • New Dynamics Ax (19)
  • Non Defined (9)
  • Note taking Apps (2)
  • Obsidian (4)
  • Personal Knowledge Management (3)
  • PKM (16)
  • Power Platform (6)
  • Procurement (5)
  • procurement and sourcing (6)
  • Product Information Management (4)
  • Product Management (6)
  • Production Control D365 for Finance and Operations (10)
  • Sale Order Process (10)
  • Sale Order Processing (10)
  • Sales and Distribution (5)
  • Soft Skill (1)
  • Supply Chain Management D365 F&O (5)
  • Tips and tricks (278)
  • Uncategorized (165)
  • Upgrade (1)
  • Web Cast (7)
  • White papers (4)
  • X++ (12)

Wiki

  • SCM

Copyright © 2026 · Magazine Pro On Genesis Framework · WordPress · Log in