Documentation Index

Fetch the complete documentation index at: https://docs.staedean.com/llms.txt

Use this file to discover all available pages before exploring further.

Add Lifecycle to a Microsoft Dynamics 365 Business Central entity

Prev

Lifecycle Base adds Lifecycle capabilities to every table entity in Microsoft Dynamics 365 Business Central. This Lifecycle functionality uses a separate set of objects and depends fully on record references.

Example

This example creates a Lifecycle for the Contact table (Table 5050).

Create a Lifecycle type

  1. Choose the   icon (Alt+Q) and type Lifecycle Types.

  2. Select New and enter the following fields:

    • Code = CONTACT

    • Description = Contact LifeCycle

    • Table Name = Contact

Setup Table and Page are needed only when you need extra functions and state settings.

Create a Lifecycle

  1. Choose the  icon (Alt+Q) and type Lifecycles.

  2. Select New and enter the following fields:

    • No. = CONTACT

    • Version Code = D365 BC

    • Description = Contact LifeCycle

    • Type Code = CONTACT

    • State Code Failed = First create the states as described below, then select the error state code here.

Select States to create the following states:

Code

Description

Editable

10-NEW

New Contact

Yes

20-EDIT

Edit Contact

Yes

30-RELEASED

Released Contact

No

99-ERROR

Failed Transition

Yes

On the Lifecycle lines, provide the following state transitions:

Code From

Code To

10-NEW

20-EDIT

20-EDIT

30-RELEASED

30-RELEASED

20-EDIT

99-ERROR

20-EDIT

You can add conditions, events, and authorizations to each state change. The PrintReport action, which prints a report for a record, is available out of the box. To learn how to create specific Action Handlers and Expressions for Conditions, contact STAEDEAN.

Modify the table

To add the status field to the table, create a table extension for table 5050 and add the following field:

    fields
    {
        field(1107100; "Lifecycle Status Code"; Code[20])
        {
            Caption = 'Lifecycle Status';
            DataClassification = CustomerContent;
            Editable = false;
        }
    }

Note

Because field number 11070100 is in the STAEDEAN range, partners cannot use that field number. For that reason, the code also looks for the field name "LifeCycle Status Code".

The Lifecycle Status Code field uses the following code in the OnLookup trigger to show the history of state changes:

// LifeCycle Status Code - OnLookup()
lRrfRecord.GETTABLE(Rec);
lCduStateMgt.RecordStatusDrillDown(lRrfRecord);

Locals:

Name

DataType

Subtype

Length

lCduStateMgt

Codeunit

N108 LifeCycle State Mgt.

lRrfRecord

RecordRef

Modify the page

Lifecycle Status field:

Type

SubType

SourceExpr

Name

Caption

Field

"LifeCycle Status Code"

LifeCycle Status Code

LifeCycle Status

Change State action:

Add the action for changing the state to the Page Actions with the following properties:

Property

Value

ID

11028250

Caption

Change Status

Image

ChangeStatus

Promoted

Yes

Promoted Category

Process

Shortcut Key

Ctrl+F9

 // OnAction()
 lRrfRecord.GETTABLE(Rec);
 lCduStateMgt.MoveRecordToNextState(lRrfRecord);
 lRrfRecord.SETTABLE(Rec);

Locals:

Name

DataType

Subtype

Length

lCduStateMgt

Codeunit

N108 LifeCycle State Mgt.

lRrfRecord

RecordRef

The end result

Use the Change Status action on the contact card to see the changes in Lifecycle Status.