web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Business Central forum

is it possible to return arrays in procedures?

(0) ShareShare
ReportReport
Posted on by 40

Hello everyone,


Is it possible to make a method that return an array in AL? For example, I have this method in a codeunit in AL:

procedure CalculatePrice(custCode: Code[20]; arrivalDate: Date; departureDate: Date; boardBasis: Code[20]; roomType: Code[20]; adults: Integer; children: Integer; children2: Integer; babies: Integer; language: Code[20]; resident: Boolean; promotion: Text[30]; onlineBooking: Boolean; OnlineBookingNo: Integer) ArrayAmount: array [100] of Text[250]

var

...

begin

...

end;

If I have the array "ArrayAmount" as a return value, it is marked as an error, that says: "Expected one of the application object keywords (table, tableextension, page, pageextension, pagecustomization, profile, codeunit, report, xmlport, query, controladdin, dotnet, enum, enumextension)", so, is it not possible to return an array in a method in AL?

Thank you,

Categories:
  • Verified answer
    I Gusti Made Ari Profile Picture
    3,608 on at

    it is not possible ,  alternatively you can add the array variable in to your function parameter and pass reference to it.

    sample :

    codeunit 50003 "Test Array"

    {

       trigger OnRun();

       begin

           Test(ArrayUp);

           MESSAGE(ArrayUp[1]); //result will be 1

       end;

       var

           ArrayUp : array [100] of Text;

       local procedure Test(var ArrayVar : array [100] of Text);

       begin

           ArrayVar[1] := '1';

       end;

    }

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Business Central

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans