microsoft / microsoft/AL

Missing compiler error when assigning a Variant to a RecordRef

Open
#8,239 1 comment 0 reactions 1 assignee View on GitHub

@esbenk is already working on this.

Since May 8, 2026.

accepted al-core-compiler bug platform-api
Dominant language
PowerShell
Stars
881
Forks
285
Avg merge
3d 36m
Merged PRs (30d)
1

Description

1. Describe the bug
Since BC 26 / runtime 15.2, an implicit conversion between Record and RecordRef is supported.

The compiler now allows us also to assign a (record based) variant to RecRef:
RecRef := SomeVariant;
But this will result in a runtime error:
The expression Microsoft.Dynamics.Nav.Runtime.NavIndirectValue cannot be type-converted to a Microsoft.Dynamics.Nav.Runtime.NavRecordRef value.

2. To Reproduce
Steps to reproduce the behavior:

Add assignment like RecRef := SomeVariant;.
Then run the code in the web client.

3. Expected behavior
Error in the AL compiler for the RecRef := SomeVariant; line, no publish possible.

4. Actual behavior
Error in the web client, which is too late.

5. Versions:

  • AL Language: v17.0.2273547
  • Business Central: 27.1
    Internal work item: AB#634365

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.