microsoft / microsoft/AL

SetLoadFields Behavior with FlowFields

Open
#8,125 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

al-docs
Dominant language
PowerShell
Stars
881
Forks
285
Avg merge
3d 36m
Merged PRs (30d)
1

Description

Let me preface this by saying I'm not sure if this is a compiler issue or a runtime issue, if it is more of a runtime issue and thus out of scope for this repository, please close this issue here and I'll report it through our partner to support instead (I don't have access to yammer as a non-partner developer).

Please include the following with each issue:

1. Describe the bug
The documentation for Record.SetLoadFields() states the following:

Only fields of FieldClass = Normal are supported as input values for the Fields parameter. If fields of FieldClass = FlowFilter or FieldClass = FlowField are passed, the return value will be false if observed; otherwise, a runtime error will occur.

Which makes sense, but doesn't work as noted. When specifying a field of type FlowField, the return value will still be true if the return value is used. Also, no runtime error occurs, if the return value isn't used (not sure what "observed" means in the documentation to be honest).

2. To Reproduce
Steps to reproduce the behavior:

  1. Create an action with an OnAction trigger
  2. Use SetLoadFields on a record variable and include a FlowField in the fields parameters
  3. Publish
  4. Use the action
AL code snippet that demonstrates the issue or a link to a code repository the developers can easily pull down to recreate the issue locally.

            action(SetLoadFieldsWithFlowField1)
            {
                trigger OnAction()
                var
                    Item: Record Item;
                    IsOK: Boolean;
                begin
                    IsOK := Item.SetLoadFields("No.", Inventory);
                    Item.FindFirst();
                    Item.CalcFields(Inventory);
                    Message(Format(IsOK)); // IsOK is true
                end;
            }
            action(SetLoadFieldsWithFlowField2)
            {
                trigger OnAction()
                var
                    Item: Record Item;
                begin
                    Item.SetLoadFields("No.", Inventory);
                    Item.FindFirst();
                    Item.CalcFields(Inventory);
                    Message(Format(Item.Inventory)); // the message outputs the value of the Inventory field
                end;
            }

Note: Because the developers need to copy and paste the code snippet, including a code snippet as a media file (i.e. .gif) is not sufficient.

3. Expected behavior
A clear and concise description of what you expected to happen.

I expected either the return value to be false, or a runtime error to occur, neither happened.

4. Actual behavior
A clear and concise description of what happened accompanied by images, animations, or a link to a video showing the issue occurring

The code compiles, publishes and runs just fine, contrary to the documentation. I also think this could be a CodeCop analyzer rule similar to AA0211. I've also had multiple coworkers ask me if including a FlowField in SetLoadFields makes the process of a CalcFields faster as that's what their AI of choice told them when generating code with FlowFields in a SetLoadFields, so an analyzer rule wouldn't hurt.

5. Versions:

  • AL Language: 16.0.1826476
  • Visual Studio Code: 1.104.3
  • Business Central: 25.6 and 26.5 DE respectively
  • List of Visual Studio Code extensions that you have installed: not applicable for this report
  • Operating System:
    • Windows
    • Linux
    • MacOS
Final Checklist

Please remember to do the following:

  • Search the issue repository to ensure you are reporting a new issue

  • Reproduce the issue after disabling all extensions except the AL Language extension

  • Simplify your code around the issue to better isolate the problem

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 by reproducing the SetLoadFields examples from the issue on the listed Business Central versions, then compare the observed behavior with the documented contract and CodeCop rule AA0211. Determine whether the fix belongs in the AL compiler, runtime, documentation, or analyzer; done means the FlowField case has a documented and consistently enforced outcome.

Written by the indexing model from the issue text.

Assessment

Domain
compilers, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.