Dynamics 365 Business Central: How to create a Wizard (NavigatePage) and Assisted Setup

Dynamics 365 Business Central

Hello everyone.
Today, let us talk about the wizard and Assisted Setup. Wizard is a step by step guidance through a setup process, and Assisted Setup is a list of setup scenarios to help Business Central User setting up a module. So In order to facilitate user settings, you should consider creating one or more Assisted Setups for your extension when creating an extension for Business Central.

For Example:
Wizard Page:

Assisted Setup:

Next, let’s try to create a new wizard page and add it to Assisted Setup page.

Wizard Page

1. Create new page of type NavigatePage for General Ledger Setup.

Set PageType property to “NavigatePage
Set SourceTable property to “General Ledger Setup

2. Add a Group for each Step (For example: four step)

3. Create global type Boolean variables, on each group, set the Visible property.

PS: You can also create global Integer variable and set the Visible property with an expression

4. Create a sub group inside the steps and add the caption and fields

For Example:
Step 1:

Step 2:

Step 3:

Step 4:

5. Add three actions to facilitate navigation.

For Example:
Names: ActionBack , ActionNext , ActionFinish
Captions: Back, Next, Finish
Set the InFooterBar property to true
Create three global variables of type Boolean: BackActionEnabled, NextActionEnabled, FinishActionEnabled
On each action, set the Enabled property to the appropriate global variable
On each action, set the Image property
Back: PreviousRecord
Next: NextRecord
Finish: Approve

Business Central:

6. Add Code for Navigation (This is not the only method, for reference only.)

Create global variables.

Create a function EnableControls

ResetControls

ShowSteps

Actions:

StoreRecordVar

Set starting values in the OnOpenPage trigger

Add OnAction triggers to the navigation actions.

7. Add Image Header (Reference standard code)

Create two global record variables for the Media Repository table and for the Media Resources table

Create two new groups above the “Step 1” Group.

Create a new function to load the top banner images

Call this function from the OnInit trigger

The development of Wizard is over.
Test:

Step 1

Step 2

Step 3:

Step 4:

Next, add it to Assisted Setup Page.

Note:
First step of Wizard page should contain Welcome message, or explanation of the wizard.
Only the Finish step should write data into actual tables.

Assisted Setup

Assisted Setup is a system codeunit which allows you to register your wizard page and execute your wizard page when the User opens it from Assisted Setup.

codeunit 3725 “Assisted Setup”

Function to add wizard page:

VideoLink and HelpLink is not required.
AssistedSetupImpl.Add(ExtensionID, PageID, AssistantName, GroupName, VideoLink, “Video Category”::Uncategorized, HelpLink, ”);

if you have translation for the name of the setup.
AssistedSetupImpl.AddSetupAssistantTranslation(PageID, LanguageID, TranslatedName);

So subscribe Assisted Setup events to register “General Ledger Setup Wizard” page.
VideoLink: ‘https://www.youtube.com/embed/hRLjl2u4I0w’ (embed link only)
HelpLink: ‘https://docs.microsoft.com/en-us/dynamics365/business-central/ui-get-ready-business’

Variables and GetAppID function.

Test

Development is all complete.

Conclusion

Maybe you will create new setup page when creating your extension. But Wizard and Assisted Setup are the best way to ask users to configure setup for your extension. You don’t even need to train users, just let them refer to the content in Assisted Setup.

You can download source code from GitHub.

PS:
If you have read the following blog and installed the extension packs, you can use Snippet to create a Wizard page in an instant.
Dynamics 365 Business Central: Two Extension Packs that will make you more productive

Dynamics 365 Business Central: AL Snippets

Update 2021/09/17

Codeunit ‘Assisted Setup’ is marked for removal. Reason: The functions from this codeunit have been consolidated in the Guided Experience codeunit.. Tag: 18.0.AL(AL0432)

Method ‘OnRegister’ is marked for removal. Reason: Replaced by OnAssistedSetupRegister() in the Guided Experience codeunit.. Tag: 18.0.AL(AL0432)

Update code:

codeunit 50100 "Gen. Ledger Setup Subscribers"
{
    [EventSubscriber(ObjectType::Codeunit, Codeunit::"Guided Experience", 'OnRegisterAssistedSetup', '', false, false)]
    local procedure AddGeneralLedgerSetupWizard()
    var
        AssistedSetup: Codeunit "Guided Experience";
        Language: Codeunit Language;
        CurrentGlobalLanguage: Integer;
    begin
        CurrentGlobalLanguage := GlobalLanguage;
        AssistedSetup.InsertAssistedSetup(SetupTxt, SetupTxt, SetupTxt, 1000, ObjectType::Page, Page::"General Ledger Setup Wizard",
                        "Assisted Setup Group"::GettingStarted, 'https://www.youtube.com/embed/hRLjl2u4I0w',
                        "Video Category"::Uncategorized,
                        'https://docs.microsoft.com/en-us/dynamics365/business-central/ui-get-ready-business');

        GlobalLanguage(Language.GetDefaultApplicationLanguageId());
        AssistedSetup.AddTranslationForSetupObjectDescription(Enum::"Guided Experience Type"::"Assisted Setup", ObjectType::Page, Page::"General Ledger Setup Wizard", Language.GetDefaultApplicationLanguageId(), SetupTxt);
        GlobalLanguage(CurrentGlobalLanguage);
    end;

    local procedure GetAppId(): Guid
    var
        EmptyGuid: Guid;
    begin
        if Info.Id() = EmptyGuid then
            NavApp.GetCurrentModuleInfo(Info);
        exit(Info.Id());
    end;

    var
        Info: ModuleInfo;
        SetupTxt: Label 'Set up General Ledger Setup';
}

Hope this will help.

Thanks.

コメント

タイトルとURLをコピーしました