SetLoadFields Behavior with FlowFields
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:
- Create an action with an OnAction trigger
- Use SetLoadFields on a record variable and include a FlowField in the fields parameters
- Publish
- 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:
- [x] Windows
- [ ] Linux
- [ ] MacOS
Final Checklist
Please remember to do the following:
-
[x] Search the issue repository to ensure you are reporting a new issue
-
[x] Reproduce the issue after disabling all extensions except the AL Language extension
-
[x] Simplify your code around the issue to better isolate the problem