Dynamics 365 for Finance and Operations Development Cookbook - Fourth Edition - Deepak Agarwal - E-Book

Dynamics 365 for Finance and Operations Development Cookbook - Fourth Edition E-Book

Deepak Agarwal

0,0
55,19 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.

Mehr erfahren.
Beschreibung

Over 80 effective recipes to help you solve real-world Microsoft Dynamics 365 for Finance and Operations development problems

About This Book

  • Learn all about the enhanced functionalities of Dynamics 365 for Finance and Operations and master development best practices
  • Develop powerful projects using new tools and features
  • Work through easy-to-understand recipes with step-by-step instructions and useful screenshots

Who This Book Is For

If you are a Dynamics AX developer primarily focused on delivering time-proven applications, then this book is for you. This book is also ideal for people who want to raise their programming skills above the beginner level, and at the same time learn the functional aspects of Dynamics 365 for Finance and Operations. Some X++ coding experience is expected.

What You Will Learn

  • Explore data manipulation concepts in Dynamics 365 for Operations
  • Build scripts to assist data migration processes
  • Organize data in Dynamics 365 for Operations forms
  • Make custom lookups using AOT forms and dynamically generate them from X++ code
  • Create a custom electronic payment format and process a vendor payment using it
  • Integrate your application with Microsoft Office Suite and other external systems using various approaches
  • Export and import business data for further distribution or analysis
  • Improve your development efficiency and performance

In Detail

Microsoft Dynamics 365 for Finance and Operations has a lot to offer developers. It allows them to customize and tailor their implementations to meet their organization's needs. This Development Cookbook will help you manage your company or customer ERP information and operations efficiently. We start off by exploring the concept of data manipulation in Dynamics 365 for Operations. This will also help you build scripts to assist data migration, and show you how to organize data in forms. You will learn how to create custom lookups using Application Object Tree forms and generate them dynamically.

We will also show you how you can enhance your application by using advanced form controls, and integrate your system with other external systems. We will help you script and enhance your user interface using UI elements. This book will help you look at application development from a business process perspective, and develop enhanced ERP solutions by learning and implementing the best practices and techniques.

Style and approach

The book follows a practical recipe-based approach, focusing on real-world scenarios and giving you all the information you need to build a strong Dynamics 365 for Finance and Operations implementation.

Sie lesen das E-Book in den Legimi-Apps auf:

Android
iOS
von Legimi
zertifizierten E-Readern

Seitenzahl: 346

Veröffentlichungsjahr: 2017

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Dynamics 365 for Finance and Operations Development Cookbook

Fourth Edition

 

 

 

 

 

 

Build extensive, powerful, and agile business solutions

 

 

 

 

 

 

Deepak Agarwal

 

Abhimanyu Singh

 

 

 

 

 

 

 

 

 

 

BIRMINGHAM - MUMBAI

Dynamics 365 for Finance and Operations Development Cookbook

Fourth Edition

 

Copyright © 2017 Packt Publishing

 

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

 

First published: December 2009

Second edition: May 2012

Third edition: April 2015

Fourth edition: August 2017

Production reference: 1100817

Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.

ISBN 978-1-78646-886-4

 

www.packtpub.com

Credits

Authors

Deepak Agarwal

Abhimanyu Singh

Copy Editor

Safis Editing

Reviewer

 

Santosh Paruvella

Project Coordinator

 

Prajakta Naik

Commissioning Editor

 

Aaron Lazer

Proofreader

 

Safis Editing

Acquisition Editor

 

Denim Pinto

Indexer

 

Francy Puthiry

Content Development Editor

 

Lawrence Veigas

Graphics

 

Abhinash Sahu

Technical Editor

 

Mehul Singh

Production Coordinator

 

Nilesh Mohite

About the Authors

Deepak Agarwal is a Microsoft Certified Professional who has more than 6 years of relevant experience. He has worked with different versions of Axapta, such as AX 2009, AX 2012, and Dynamics 365. He has had a wide range of development, consulting, and leading roles, while always maintaining a significant role as a business application developer. Although his strengths are rooted in X++ development, he is a highly regarded developer and expert in the technical aspects of Dynamics AX development and customization. He has also worked on base product development with the Microsoft team.

He was awarded the Most Valuable Professional (MVP) award from Microsoft for Dynamics AX four times in a row, and he has held this title since 2013.

He shares his experience with Dynamics AX on his blog Axapta V/s Me.

Deepak has also worked on the following Packt books:

Microsoft Dynamics AX 2012 R3 Reporting Cookbook

Dynamics AX 2012 Reporting Cookbook

Microsoft Dynamics AX 2012 Programming: Getting Started

 

I would like to thank my wife for her support during this duration. Big thanks for her understanding while I spent late hours working on this book. Thanks to my co-author, Abhimanyu, and the Packt team for their support and efforts.

 

 

 

Abhimanyu Singhworks as a Microsoft Dynamics 365 for Finance and Operations consultant. Since the start of his career in 2012, he has worked in the development and designing of business solutions for customers in supply chain management, banking, and finance domain using Microsoft technologies. He has several certifications, including the Microsoft Certified Dynamics Specialist certification.

 

I would like to thank my parents, sister, and brother-in-law for their support and inspiration during the time spent on this book. Secondly, I wish to thank the co-author of this book, and my friend, Deepak Agarwal--a very experienced Dynamics AX consultant.

About the Reviewer

Santosh Paruvella has 12 years of experience in Dynamics AX, and he has worked on various versions of it, from 3.0 to 2012, and Dynamics 365 for Finance and Operations. He is presently working as a Technical Architect and Lead for various implementation projects, designing the solutions and leading the team towards successful implementations.

 

I have got the chance to review this Dynamics 365 for finance and Operations Development Cookbook, and I am very thankful to the Packt team and the author for this opportunity. This is a very good book for beginners to start with AX development.

www.PacktPub.com

For support files and downloads related to your book, please visit www.PacktPub.com. Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.comand as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at [email protected] for more details.

At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.

https://www.packtpub.com/mapt

Get the most in-demand software skills with Mapt. Mapt gives you full access to all Packt books and video courses, as well as industry-leading tools to help you plan your personal development and advance your career.

Why subscribe?

Fully searchable across every book published by Packt

Copy and paste, print, and bookmark content

On demand and accessible via a web browser

Customer Feedback

Thanks for purchasing this Packt book. At Packt, quality is at the heart of our editorial process. To help us improve, please leave us an honest review on this book's Amazon page at https://www.amazon.com/dp/1786468867.

If you'd like to join our team of regular reviewers, you can e-mail us at [email protected]. We award our regular reviewers with free eBooks and videos in exchange for their valuable feedback. Help us be relentless in improving our products!

This book is dedicated to my grandpa, the late Mr. M.R. Agarwal. You are always a blessing indeed.
- Deepak Agarwal

Table of Contents

Preface

What this book covers

Exceptions and considerations

What you need for this book

Who this book is for

Sections

Getting ready

How to do it...

How it works...

There's more...

See also

Conventions

Reader feedback

Customer support

Downloading the example code

Errata

Piracy

Questions

Processing Data

Introduction

Creating a new project, package, and model

How to do it...

There's more...

Creating a new number sequence

How to do it...

How it works...

See also

Renaming the primary key

How to do it...

How it works...

Adding a document handling note

Getting ready

How to do it...

How it works...

Using a normal table as a temporary table

How to do it...

How it works...

Copying a record

How to do it...

How it works...

There's more...

Building a query object

How to do it...

How it works...

There's more...

Using the OR operator

See also

Using a macro in a SQL statement

How to do it...

How it works...

Executing a direct SQL statement

How to do it...

How it works...

There's more...

Enhancing the data consistency checks

Getting ready

How to do it...

How it works...

There's more...

Using the date effectiveness feature

How to do it...

How it works...

Working with Forms

Introduction

Creating dialogs using the RunBase framework

How to do it...

How it works...

Handling the dialog event

How to do it...

How it works...

See also

Creating dialogs using the SysOperation framework

Getting ready

How to do it...

Building a dynamic form

How to do it...

How it works...

Adding a form splitter

How to do it...

How it works...

Creating a modal form

How to do it...

How it works...

There's more...

See also

Modifying multiple forms dynamically

How to do it...

How it works...

Storing the last form values

How to do it...

How it works...

Using a tree control

How to do it...

How it works...

See also

Adding the View details link

How to do it...

How it works...

Selecting a form pattern

How to do it

Full list of form patterns

How to do it...

Creating a new form

Getting ready

How to do it...

How it works...

Working with Data in Forms

Introduction

Using a number sequence handler

How to do it...

How it works...

See also

Creating a custom filter control

How to do it...

How it works...

See also

Creating a custom instant search filter

How to do it...

How it works...

See also

Building a selected/available list

How to do it...

How it works...

There's more...

Creating a wizard

How to do it...

How it works...

Processing multiple records

How to do it...

How it works...

Coloring records

Getting ready

How to do it...

How it works...

See also

Adding an image to records

How to do it...

How it works...

There's more...

Displaying an image as part of a form

Saving a stored image as a file

Building Lookups

Introduction

Creating an automatic lookup

How to do it...

How it works...

There's more...

Creating a lookup dynamically

How to do it...

How it works...

There's more...

Using a form to build a lookup

How to do it...

How it works...

See also

Building a tree lookup

How to do it...

How it works...

See also

Displaying a list of custom options

How to do it...

How it works...

There's more...

Displaying custom options in another way

How to do it...

How it works...

There's more...

Building a lookup based on the record description

How to do it...

How it works...

There's more...

Building the browse for folder lookup

How to do it...

How it works...

There's more...

Creating a color picker lookup

How to do it...

How it works...

Processing Business Tasks

Introduction

Using a segmented entry control

How to do it...

How it works...

There's more...

See also

Creating a general journal

How to do it...

How it works...

There's more

See also

Posting a general journal

How to do it...

How it works...

See also

Processing a project journal

How to do it...

How it works...

There's more...

Creating and posting a ledger voucher

How to do it...

How it works...

See also

Changing an automatic transaction text

Getting ready

How to do it...

How it works...

There's more...

Creating a purchase order

How to do it...

How it works...

There's more...

Posting a purchase order

How to do it...

How it works...

There's more...

Creating a sales order

How to do it...

How it works...

There's more...

Posting a sales order

How to do it...

How it works...

There's more...

Creating an electronic payment format

How to do it...

How it works...

Data Management

Introduction

Data entities

Getting ready

How to do it...

How it works...

There's more...

Building a data entity with multiple data sources

How to do it...

How it works...

There's more...

Data packages

Getting ready...

How to do it...

There's more...

See also

Data migration

Getting ready

How to do it...

How it works...

Importing data

How to do it...

How it works...

Troubleshooting

Getting ready

How to do it...

How it works...

There's more...

Integration with Microsoft Office

Introduction

Configuring and using the Excel Data Connector add-in

How to do it...

How it works...

Using Workbook Designer

How to do it...

How it works...

Export API

How to do it...

How it works...

Lookup in Excel - creating a custom lookup

How to do it...

How it works...

Document management

How to do it...

How it works...

There's more...

Integration with Power BI

Introduction

Configuring Power BI

How to do it...

How it works...

There's more...

See also

Consuming data in Excel

How to do it...

How it works...

See also

Integrating Excel with Power BI

How to do it...

How it works...

See also

Developing interactive dashboards

How to do it...

How it works...

Embedding Power BI visuals

How to do it...

How it works...

Integration with Services

Introduction

Authenticating a native client app

Getting ready

How to do it...

How it works...

There's more...

See also

Creating a custom service

Getting ready

How to do it...

How it works...

Consuming custom services in JSON

Getting ready

How to do it...

How it works...

There's more...

Consuming custom services in SOAP

Getting ready

How to do it...

How it works...

Consuming OData services

Getting ready

How to do it...

How it works...

There's more...

See also

Consuming external web services

Getting ready

How to do it...

How it works...

There's more...

See also

Improving Development Efficiency and Performance

Introduction

Using extensions

How to do it...

How it works...

Caching a display method

How to do it...

How it works...

There's more...

Calculating code execution time

How to do it...

How it works...

There's more...

Enhancing insert, update, and delete operations

How to do it...

How it works...

There's more...

Using delete_from

Using update_recordSet for faster updates

Writing efficient SQL statements

How to do it...

How it works...

There's more...

See also

Using event handler

How to do it...

How it works...

There's more...

Creating a Delegate method

Getting ready...

How to do it...

How it works...

There's more...

See also

Preface

As a Dynamics 365 for Finance and Operations developer, your responsibility is to deliver all kinds of application customization, whether small adjustments or a bespoke modules. Dynamics 365 for Finance and Operations is a highly customizable system and requires a significant amount of knowledge and experience to deliver quality solutions. One goal can be achieved in multiple ways, and there is always the question of which way is the best.

This book takes you through numerous recipes to help you with daily development tasks.

Each recipe contains detailed step-by-step instructions along with the application screenshots and in-depth explanations. The recipes cover multiple Dynamics 365 for Financial and Operations modules, so, at the same time, the book provides an overview of the functional aspects of the system for developers.

What this book covers

Chapter 1, Processing Data, focuses on data manipulation. It explains how to build data queries, check and modify existing data, read and write external files, and use data effectively.

Chapter 2, Working with Forms, covers various aspects of building forms in Dynamics 365 for Finance and Operations. In this chapter, dialogs and their events are explained. Also, various useful features, such as splitters, tree controls, and checklists, are explained.

Chapter 3, Working with Data in Forms, basically supplements Chapter 2, Working with Forms, and explains the data organization in forms. The examples in this chapter include instructions for building filter controls on forms, processing multiple records, and working with images and colors.

Chapter 4, Building Lookups, covers all kinds of lookups in the system. This chapter starts with a simple, automatically generated lookup, continues with more advanced ones, and finishes with standard Windows lookups, such as the file selection dialog and the color picker.

Chapter 5, Processing Business Tasks, explains how to use the Dynamics 365 for Finance and Operations business logic API. In this chapter, topics such as how to process journals, purchase orders, and sales orders are discussed. Other features, such as posting ledger vouchers, modifying transaction texts, and creating electronic payment formats, are included as well.

Chapter 6, Data Management, explains the data management and data entity concepts, how to build a data entity, data packages, and import and export in Dynamics 365 for Financial and Operations.

Chapter 7, Integration with Microsoft Office, explains how to configure and use the Excel Data Connector add-in, and design Excel workbooks with the data feed from Dynamics 365 from Operations using OData. It also covers how to use the export API and document management.

Chapter 8, Integration with Power BI, explains the configuration of Power BI and its integration with Dynamics 365 for Financial and Operations to develop interactive dashboards and embed them in Dynamics 365 for Financial and Operations workspaces.

Chapter 9, Integration with Services, explains how to use services in Dynamics 365 for Financial and Operations. This chapter covers how to create services, authentication, SOAP applications, JSON applications, and OData services. It also demonstrates how to consume external services.

Chapter 10, Improving Development Efficiency and Performance, presents a few ideas on how to make daily development tasks easier. It discusses how system performance can be improved by following several simple rules. This chapter explains how to calculate code execution time, how to write efficient SQL statements, and how to properly cache display methods.

Exceptions and considerations

The code in this book follows the best practice guidelines provided by Microsoft, but there are some exceptions:

No text labels were used to make the code clear

No three-letter code was used in front of each new AOT object

No configuration or security keys were used

Object properties that are not relevant to the topic being discussed are not set

Also, here are some considerations that you need to keep in mind when reading this book:

Each recipe only demonstrates the principle and is not a complete solution

The data in your environment might not match the data used in the recipes, so the code might have to be adjusted appropriately

For each recipe, the assumption is that no other modifications are present in the system, unless it is explicitly specified

The code might not have all the possible validations that are not relevant to the principle being explained

The code might have more variables than required in order to ensure that it is clear for all audiences

Sometimes, unnecessary code wrapping is used to make sure the code fits into the page width of this book and is easily readable

What you need for this book

All the coding examples were performed in a Microsoft Azure-hosted Microsoft Dynamics 365 for Financial and Operations environment. The following list of software from the virtual image was used in this book:

Microsoft Dynamics 365 for Financial and Operations (Update 6)

Microsoft Visual studio 2015

Microsoft Windows Server 2015 Enterprise

Microsoft SQL Server 2016

Microsoft Power BI

Microsoft Office Excel 2015

Microsoft Office Word 2015

Microsoft Internet Explorer

Windows Notepad

Although all the recipes have been tested on the previously-mentioned software, they may work on older or newer software versions with minor code adjustments. As Microsoft is continuously evolving on Dynamics 365 for Financial and Operations, we might see some differences while using the same code in older or newer updates of application. Stick to the concept and customize or extend the application.

Who this book is for

If you are a Dynamics AX developer primarily focused on delivering time-proven applications, then this book is for you. This book is also ideal for people who want to raise their programming skills above the beginner level, and, at the same time, learn the functional aspects of Dynamics 365 for Financial and Operations. Some X++ coding experience is expected.

Sections

In this book, you will find several headings that appear frequently (Getting ready, How to do it, How it works, There's more, and See also).

To give clear instructions on how to complete a recipe, we use these sections as follows:

Getting ready

This section tells you what to expect in the recipe, and describes how to set up any software or any preliminary settings required for the recipe.

How to do it...

This section contains the steps required to follow the recipe.

How it works...

This section usually consists of a detailed explanation of what happened in the previous section.

There's more...

This section consists of additional information about the recipe in order to make the reader more knowledgeable about the recipe.

See also

This section provides helpful links to other useful information for the recipe.

Conventions

In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "Then, to override the data source's write() method."

A block of code is set as follows:

[FormDataSourceEventHandler(formDataSourceStr(CustGroup, CustGroup), FormDataSourceEventType::Written)] public void CustGroup_OnWritten(FormDataSource sender, FormDataSourceEventArgs e) { this.numberSeqFormHandler().formMethodDataSourceWrite(); }

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "Clicking the Next button moves you to the next screen."

Warnings or important notes appear like this.
Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book-what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail [email protected], and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for this book from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

You can download the code files by following these steps:

Log in or register to our website using your e-mail address and password.

Hover the mouse pointer on the

SUPPORT

tab at the top.

Click on

Code Downloads & Errata

.

Enter the name of the book in the

Search

box.

Select the book for which you're looking to download the code files.

Choose from the drop-down menu where you purchased this book from.

Click on

Code Download

.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

WinRAR / 7-Zip for Windows

Zipeg / iZip / UnRarX for Mac

7-Zip / PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Dynamics-365-for-Finance-and-Operations-Development-Cookbook-Fourth-Edition. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books-maybe a mistake in the text or the code-we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at [email protected] with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.

Questions

If you have a problem with any aspect of this book, you can contact us at [email protected], and we will do our best to address the problem.

Processing Data

In this chapter, we will cover the following recipes:

Creating a new project, package, and model

Creating a new number sequence

Renaming the primary key

Adding a document handling note

Using a normal table as a temporary table

Copying a record

Building a query object

Using a macro in a SQL statement

Executing a direct SQL statement

Enhancing the data consistency checks

Using the date effectiveness feature

Introduction

This chapter focuses on data manipulation exercises in all new Dynamics 365 for Finance and Operations. These exercises are very useful when doing data migration, system integration, custom reporting, and so on. Here, we will discuss how to work with query objects from the X++/C# code. We will also discuss how to reuse macros in X++ SQL statements and how to execute SQL statements directly to the database. This chapter will explain how to rename primary keys, how to merge and copy records, how to add document handling notes to selected records, and how to create and read XML and comma-separated files. The chapter ends with a recipe about the date effectiveness feature.

Creating a new project, package, and model

Elements in Dynamics 365 for Finance and Operations represent every individual element of AOT such as class, table, form, and so on. Elements in Dynamics 365 for Finance and Operations are stored on disk as XML files; these files contain the metadata and source code for the element. The XML files are the unit of Source Control.

Projects works the same as AX2012, but in D365 an element can be customized only once they are added to a specific Visual Studio project. The project may only belong to one model.

A Dynamics 365 for Finance and Operations model is a group of elements. Standard elements are part of a standard model; you can add them into your model and do customization. A model is a design-time concept. An example of models: warehouse management model, a project accounting model, and more. Models can have one or more projects. Models may only belong to one package.

A Dynamics 365 for Finance and Operations package is a deployment and compilation unit of one or more models. It includes model metadata, binaries, cubes, and other associated resources. One or more D365 packages can be packaged into a deployment package, which is the vehicle used for deployment on UAT and production environments. Packages are packaged into a deployable package file for deployment to Sandbox or production environments. A package can have one or more models. Packages can have references to other packages, just like .NET assemblies can reference each other.

How to do it...

To create a new project, follow these steps:

Open Visual Studio as admin.

On the

File

menu, point to

New

, and then click

Project

.

In the list of template types, expand the

Installed

node.

Expand the

Templates

node.

Select the

Microsoft Dynamics 365 for Operations

category.

Select the

D365 Project

template.

Enter the name and location for the new project.

Select

Create directory for solution

if you want to create a new solution for this project, uncheck if you want to add in your current solution.

To create a new model, follow these steps:

Open Visual Studio as admin.

On the

Dynamics 365

menu, point to

Model management

and select

Create model

.

Give a model, publisher name, and other values:

Now here you can create a new package or select any existing package. We could create a new package and select the required package as referenced packages:

Double-check the summary with details. Select

Create new project

if you want to create a new project in this model once created. You can mark this model to all your new projects by selecting options:

There's more...

As you saw, there was one more step while creating a model, Select referenced packages. When you create your own package you can select from an existing package to add them as references in your new package. You may need to add some standard package reference if you want to add them into your customization.

Here are the steps to create a new package:

Open Visual Studio as admin.

On the

Dynamics 365

menu, point to Model management and select

Create model.

Give a model, publisher name, and other values.

On the next step select

Create new package

Give a name to your package.

Next select the existing package as a reference to this new package.

Click on

Finish

.

So now you have your own model with a new package.

Creating a new number sequence

Number sequences in Dynamics 365 for Finance and Operations are used to generate specifically formatted numbers for record identification. These number sequences can be anything from voucher numbers or transaction identification numbers to customer or vendor accounts.

When developing custom functionality, often one of the tasks is to add a new number sequence to the system in order to support newly created tables. Adding a number sequence to the system is a two-step process. First, we create the number sequence itself; second, we start using it in some particular form or from the code.

D365 contains a list of NumberSeqApplicationModule derivative classes, which hold the number sequence's setup data for the specific module. These classes are read by the number sequence wizard, which detects existing number sequences and proposes to create the missing ones or newly added ones. The wizard is normally run as a part of the application initialization. It can also be rerun any time later when expanding the D365 functionality used, where a setup of additional number sequences is required. The wizard also has to be rerun if new custom number sequences are added to the system.

In this recipe, we will do the first step, that is, add a new number sequence to the system. In a standard application, the customer group number is not driven by any number sequence, so we will enhance this by creating it. The second step is explained later in the Using a number sequence handler recipe in Chapter 3, Working with Data in Forms.

How it works...

We start the recipe by adding a number sequence initialization code into the NumberSeqModuleCustomer_packt class. As understood from its name, the number sequence initialization code holds the initialization of the number sequences that belong to the Accounts receivable module.

The code in the loadModule_Extension() method defines the default number sequence settings to be used in the wizard, such as the data type, description, and highest possible number. Additional options such as the starting sequence number, number format, and others can also be added here. All the mentioned options can be changed while running the wizard. The addParameterType() method is used to define the number sequence scope. In the example, we created a separate sequence for each Legal entity.

Before we start the wizard, we initialize number sequence references. This should be done as a part of the Dynamics 365 for Finance and Operations initialization checklist, but in this example, we execute it manually by calling the loadModule_Extension() method of the NumberSeqApplicationModule_packt class.

Next, we execute the wizard that will create the number sequences for us. We skip the welcome page and in the second step of the wizard, the Details button can be used to display more options. The options can also be changed later in the Number sequences form before or even after the number sequence is actually used. The last page shows an overview of what will be created. Once completed, the wizard creates new records in the Number sequences form for each company.

The newly created number sequence reference appears in the Segment configuration form. Here, we can see that the Data area checkbox is checked, which means that we will have separate number lists for each company. The number sequence setup can be normally located in the module parameter forms.

See also

The

Using a number sequence handler

recipe in

Chapter 3

,

Working with Data in Forms

Renaming the primary key

Most of you who are familiar with the Dynamics 365 for Finance and Operations application, have probably used the standard Rename function. This function allows you to rename the primary key of almost any record. With this function, you can fix records that were saved or created by mistake. This function ensures data consistency, that is, all the related records are renamed as well. It can be accessed from the Record information form (shown in the following screenshot), which can be opened by selecting Record info from the right-click menu on any record:

A new form will open as follows:

Click on the Rename button to rename the Vendor Account field value.

When it comes to mass renaming, this function might be very time-consuming as you need to run it on every record. An alternative way of doing this is to create a job that automatically runs through all the required records and calls this function automatically.

This recipe will explain how the record's primary key can be renamed through the code. As an example, we will create a job that renames a vendor account.

How it works...

In this recipe, we first select the desired vendor record and set its account number to the new value. Note that only the fields belonging to the table's primary key can be renamed in this way.

Then, we call the table's renamePrimaryKey() method, which does the actual renaming. The method finds all the related records for the selected vendor account and updates them with the new value. The operation might take a while, depending on the volume of data, as the system has to update multiple records located in multiple tables.

Adding a document handling note

Document handling in Dynamics 365 for Finance and Operations is a feature that allows you to add notes, links, documents, images, files, and other related information to almost any record in the system. For example, we can track all the correspondence sent out to our customers by attaching the documents to their records in Dynamics 365 for Finance and Operations. Document handling on most of the forms can be accessed either from the Action pane by clicking on the Attachments button and selecting Document handling from the Command menu under File or selecting the Document handling icon from the status bar.