microsoft / microsoft/BCApps

[Bug]: "Guided Experience Impl." OnRegisterVideo subscriber does not correctly populate the Product Video buffer from Guided Experience Item records due to error in condition

Open Beginner friendly
#11,497 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Team: Integrations
Dominant language
AL
Stars
683
Forks
459
Avg merge
3d 26m
Merged PRs (30d)
633

Description

Describe the issue

In the Guided Experience Impl. codeunit there is the following event subscriber which is intended for populating the "Product Videos" page with product videos based on the Assisted Setup videos stored in Guided Experience Item records.

    [EventSubscriber(ObjectType::Codeunit, Codeunit::Video, OnRegisterVideo, '', false, false)]
    local procedure OnRegisterVideo(Sender: Codeunit Video)
    var
        GuidedExperienceItem: Record "Guided Experience Item";
        PrevGuidedExperienceItem: Record "Guided Experience Item";
        GuidedExperience: Codeunit "Guided Experience";
    begin
        GuidedExperience.OnRegisterAssistedSetup();

        GuidedExperienceItem.SetCurrentKey("Object Type to Run", "Object ID to Run", Link, Version);
        GuidedExperienceItem.SetFilter("Video Url", '<>%1', '');
        if GuidedExperienceItem.FindSet() then begin
            repeat
                if (PrevGuidedExperienceItem."Object ID to Run" <> 0) and
                    ((GuidedExperienceItem."Object Type to Run" <> PrevGuidedExperienceItem."Object Type to Run") or (GuidedExperienceItem."Object Type to Run" <> PrevGuidedExperienceItem."Object Type to Run")) then
                    Sender.Register(PrevGuidedExperienceItem."Extension ID", CopyStr(PrevGuidedExperienceItem.Title, 1, 250), PrevGuidedExperienceItem."Video Url",
                        PrevGuidedExperienceItem."Video Category", Database::"Guided Experience Item", PrevGuidedExperienceItem.SystemId);

                PrevGuidedExperienceItem := GuidedExperienceItem;
            until GuidedExperienceItem.Next() = 0;

            Sender.Register(GuidedExperienceItem."Extension ID", CopyStr(GuidedExperienceItem.Title, 1, 250), GuidedExperienceItem."Video Url",
                GuidedExperienceItem."Video Category", Database::"Guided Experience Item", GuidedExperienceItem.SystemId);
        end;
    end;

But, there is an error here:

 if (PrevGuidedExperienceItem."Object ID to Run" <> 0) and
                    ((GuidedExperienceItem."Object Type to Run" <> PrevGuidedExperienceItem."Object Type to Run") or (GuidedExperienceItem."Object Type to Run" <> PrevGuidedExperienceItem."Object Type to Run")) then
    ...

should most likely be replaced with

 if (PrevGuidedExperienceItem."Object ID to Run" <> 0) and
                    ((GuidedExperienceItem."Object Type to Run" <> PrevGuidedExperienceItem."Object Type to Run") or (GuidedExperienceItem."Object ID to Run" <> PrevGuidedExperienceItem."Object ID to Run")) then
    ...

Due to this error, the video for only one extension is added to the Product Videos page, and for all other extensions the videos are not added/available.

Could you please let me know if you agree with the suggested bug fix? Because this is also what I would submit, when I am getting approval for this issue to make a PR.

Expected behavior

The "Product Videos" page only shows the video of the first extension/assisted setup page, and not for any other extensions that provide a product video.

Steps to reproduce

Use the following code:

    local procedure AddAssistedSetupRecord1()
    var
        GuidedExperience: Codeunit "Guided Experience";
        IsPrimarySetup: Boolean;
        SetupWizardDescTxt: Label 'A nice description.', MaxLength = 1024;
        SetupWizardTxt: Label 'Start the setup of 1';
        SetupWizardVideoURLTxt: Label 'https://www.youtube.com/embed/12345', Locked = true;
    begin
        IsPrimarySetup := true;
        GuidedExperience.InsertAssistedSetup(
            SetupWizardTxt, CopyStr(SetupWizardTxt, 1, 50), SetupWizardDescTxt, 0,
            ObjectType::Page, Page::SetupWizard1, Enum::"Assisted Setup Group"::Extensions, SetupWizardVideoURLTxt, Enum::"Video Category"::Extensions, GetAppHelpLink1(), IsPrimarySetup);
    end;

    local procedure AddAssistedSetupRecord2()
    var
        GuidedExperience: Codeunit "Guided Experience";
        IsPrimarySetup: Boolean;
        SetupWizardDescTxt: Label 'A nice description.', MaxLength = 1024;
        SetupWizardTxt: Label 'Start the setup of 2';
        SetupWizardVideoURLTxt: Label 'https://www.youtube.com/embed/67890', Locked = true;
    begin
        IsPrimarySetup := true;
        GuidedExperience.InsertAssistedSetup(
            SetupWizardTxt, CopyStr(SetupWizardTxt, 1, 50), SetupWizardDescTxt, 0,
            ObjectType::Page, Page::SetupWizard2, Enum::"Assisted Setup Group"::Extensions, SetupWizardVideoURLTxt, Enum::"Video Category"::Extensions, GetAppHelpLink2(), IsPrimarySetup);
    end;

    [EventSubscriber(ObjectType::Codeunit, Codeunit::"Guided Experience", OnRegisterAssistedSetup, '', false, false)]
    local procedure CodeunitGuidedExperience_OnRegisterAssistedSetup()
    begin
        AddAssistedSetupRecord1();
        AddAssistedSetupRecord2();
    end;

Then, with this code published and installed, open the "Product Videos" page. Only 1 of the 2 product videos will be available, but both (and any other) should be available.

Additional context

This is when you link a product video via InsertAssistedSetup, which is a common practice.

A possible work-around is to subscribe to the OnRegisterVideo publisher yourself, but that comes with the risk of having the video double when a bug fix for this is eventually deployed.

I will provide a fix for a bug
  • I will provide a fix for a bug

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the Guided Experience Impl. OnRegisterVideo subscriber shown in the issue and reproduce the problem with two InsertAssistedSetup records, each providing a video. Verify the Product Videos page contains both videos after the fix, rather than only one extension's video.

Written by the indexing model from the issue text.

Assessment

Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.