Dynamics Business Central / NAV Developer Digest - Vol. 504

Dynamics Business Central / NAV Developer Digest - Vol. 504

ArcherPoint’s Developer Digest focuses on Microsoft Dynamics 365 Business Central and Dynamics NAV development. This week’s volume includes maintaining Business Central Online databases, refresh needed for Power Automate workflows, managing breaking changes with AppSource apps, and the upcoming Community Summit NA 2024.

The Dynamics 365 Business Central community, consisting of developers, project managers, and consultants, collaborates across various platforms to share valuable insights. At ArcherPoint, we greatly value their dedication and expertise. To ensure widespread access to this technical knowledge, we created Developer Digest.

Does AI help developers with productivity?

Kyle Hardin shares an article from CIO.com that states that developers gain little (if anything) from AI coding assistants, adding “that copilot in VSC is spicy auto-complete, and as long as I use it that way, it makes me more productive. If I try to have it write larger blocks of code – anything more than a line or two, that’s when the issues the article mentions start to happen, where you spend more time in cleanup than if you’d written it yourself. Do I think it is worth $10 a month? Absolutely. I just hope it continues to improve so I can use it for larger blocks of code.” Tom Hunt agrees, saying “I’m with you. Copilot does pretty well with small, repetitive tasks, but it breaks down quickly when it has to do heavy lifting.”

Jon pipes in, “ChatGPT is really good at explaining what code does. Last week, I used it for some really ugly, lengthy, complicated code that used naming conventions only a computer would be able to figure out. ChatGPT spits out a very nice description of what the code does. I was able to get this to a client (because they asked for it) in 2 hours. I spent an hour on the analysis, then just for fun asked ChatGPT to tell me what this code does and decided to add that at the bottom for a deeper summarization. Clients love deep summarizations, especially when they are virtually free.”

Difference between OnAfterGetRecord() and OnAfterGetCurrRecord()

Kyle is back, posing this question to the ArcherPoint developer crew: “What is the difference between the page triggers OnAfterGetRecord() and OnAfterGetCurrRecord()?”

Yann responds with: “I believe the AI is correct here…

Chat-GPT:

In Business Central development, the **`OnAfterGetRecord`** and **`OnAfterGetCurrentRecord`** triggers are used in pages, but they serve different purposes and are triggered at different times in the process of interacting with records. Here’s a breakdown of the differences:

### 1. **OnAfterGetRecord**

– **Trigger context**: This trigger is called **after each record** is retrieved or fetched from the data source (e.g., table) in a loop. It is triggered for every record in the dataset when navigating, filtering, or loading a list of records.

– **Common use case**: Typically used in list pages or repeated record contexts (like a subpage), where actions or calculations are needed after retrieving each individual record in the list.

– **Example**: If you are working with a list page, this trigger is invoked for every record shown in the list as it is loaded, allowing you to modify or take action on each one.

### 2. **OnAfterGetCurrentRecord**

– **Trigger context**: This trigger is called **after the user interacts with the current record**. This could be when the user selects a record in a list or form and performs an action, such as clicking a button or navigating to a new page.

– **Common use case**: Used when you need to take action or perform a calculation based on the currently selected record. This is often useful in card pages or scenarios where you need to update or react to changes in the currently active record (e.g., updating fields based on selections).

– **Example**: In a card page, this trigger is fired when the user moves from one record to another or when a record is specifically selected.

### Key Differences:

– **`OnAfterGetRecord`** is triggered for each record in a set (e.g., a list or subpage), whereas **`OnAfterGetCurrentRecord`** is triggered only for the record currently selected or interacted with by the user.

– **`OnAfterGetRecord`** is more general and runs as part of the record-fetching process for displaying records, while **`OnAfterGetCurrentRecord`** is specific to user interaction with a record.

Elyes posed the same question to Centralq.ai and received this response:

Are you interested in Dynamics NAV and Business Central development? Check out our collection of NAV/BC Development Blogs.

Read “How To” blogs from ArcherPoint for practical advice on using Microsoft Dynamics NAV and Dynamics 365 Business Central.

Trending Posts

Stay Informed

Choose Your Preferences
First Name
*required
Last Name
*required
Email
*required
Subscription Options
Your Privacy is Guaranteed