Diagram of two curved arrows forming a cycle between the labels RecRef and Record, illustrating implicit conversion between them.

AL Language: Implicit conversion between Record and RecordRef

1 min read

From version 15.0 of AL Extension there is a very cool and useful feature shipped!

Now its supported implicit conversion between Record and RecordRef instances, allowing direct assignment between these types.

So, it’s important that you have runtime 15.0 at least defined in your app.json:

app.json snippet showing runtime set to 15.0.


Examples

Record to RecordRef:

AL code example converting a Record Customer to RecordRef and passing it to a procedure.

Now two things here:

  1. Direct assignment to RecRef from Record

RecRef := Customer;

It would do same thing as Rec.Ref.GetTable(Customer);

2. Argument conversion, assign Record (Customer) to RecRef parameter ofthe procedure

RecRef to Record:

AL code example assigning RecordRef to Record Customer and passing the values to another procedure.

Also, two things here:

  1. Direct assigment of RecRef to Record (Customer)

Customer := RecRef;

Here the error will be thrown if RecRef is different table then Record to which RecRef is being assigned.

2. Argument conversion, call procedure which has Record (Customer) parameter with RecRef


This change makes work with the RecRef much easier now. Try it out! 🚀

Related posts

Comments

    Leave a comment

    Reviewed before it appears.