HOW DO I : CREATE A REPORT AND LAYOUT IN VS CODE

In your project, create a new file, for example: MyReport.al. In the Report.al file, use the treport snippet to create a report and then change the ID, Name and add fields and an option page, as in the following example:

Type treport followed by the Tab key. This snippet will create a basic layout for a report object.

Format for Single dataitem:-

report 50100 “Reward report”

{

CaptionML = ENU = ‘MyRewardList’;

dataset

{

dataitem(Reward; Reward)

{

RequestFilterFields = “Reward ID”;

column(Reward_ID; “Reward ID”) { }

column(Description; Description) { }

column(Discount_Percentage; “Discount Percentage”) { }

}

}

}

Format for Two DataItem:-

report 50100 “Reward report”
{
CaptionML = ENU = ‘MyRewardList’;
RDLCLayout = ‘Report/RewardReport.rdl’;
dataset
{
dataitem(Reward; Reward)
{
RequestFilterFields = “Reward ID”;
column(Reward_ID; “Reward ID”) { }
column(Description; Description) { }
column(Discount_Percentage; “Discount Percentage”) { }
dataitem(Reward1; Reward)
{
DataItemLinkReference = reward;
DataItemTableView = sorting (“Reward ID”);
PrintOnlyIfDetail = false;
DataItemLink = “Reward ID” = field (“Reward ID”);
column(Reward_ID1; “Reward ID”) { }
column(Description1; Description) { }
column(Discount_Percentage1; “Discount Percentage”) { }
}
}
}
}

Press Ctrl +F5 to publish the report. Once you publish the report it will be available in report layout selection table.

Report 1

Select Option Custom Layout and edit the layout.

Report 2

Once you select the edit layout it will open in SQL Report Builder. Where you can design your report.

Report 3

Report 4

After that select Export layout to save the file in .rdl format in your project folder.

Report 5

Report 7

Now in the MyReport.AL file you need to reference the layout, for example as follows:

report 50100 “Reward report”

{

CaptionML = ENU = ‘MyRewardList’;

RDLCLayout = ‘Report/RewardReport.rdl’;

WordLayout = ‘Report/RewardReport.docx’;

DefaultLayout = RDLC;

Now when you redeploy the extension and run the report, you see:

Report 8

report-9.png

That’s all it takes to add an RDLC and WORD layout to a report, using the new development environment, VSCode.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s