How to do it...

  1. Extract ch5-post-conversion-cleanup-start.zip to a folder on your machine. You should have the alCleanupProject folder.
  2. In Visual Studio Code, open the alCleanUpProject folder. You need to connect this project to your AL development sandbox. You can reuse the launch.json file from the previous recipe or create a new one. You can refer back to Chapter 1Let's Get the Basics Out of the Way, and the recipe, Setting up your development sandbox, for how to do thisOnce the project has been connected, you need to download the symbols.
  3. In Explorer, select Modification - Item(Table 27).al and find the block of code that starts with the following:
//Unsupported feature: Code Modification on "CheckDocuments(PROCEDURE 23)".

This is an example of where a call to a new function, DoCustomDocumentCheck(), was added in the middle of the existing CheckDocuments() base function. In order to address this, we can move our function call to an event subscriber and then subscribe to the OnAfterCheckDocuments() event that is at the end of the base function.

  1. In Explorer, create a new file named Item Table Subscribers.al and enter the following code in Editor:
codeunit 50000 "Item Table Subscribers"
{
[EventSubscriber(ObjectType::Table,
Database::Item, 'OnAfterCheckDocuments', '', False, False)]
local procedure OnAfterCheckDocuments(var
Item: Record Item; var CurrentFieldNo: Integer)
begin
Item.DoCustomDocumentCheck(CurrentFieldNo);
end;
}
  1. In Explorer, select Modification - Item(Table 27).al and remove the local attribute from the DoCustomDocumentCheck() function. Don't worry – this function was intentionally left empty. You can delete the commented block of code for the unsupported feature.
  1. In Explorer, select Modification - Item Card(Page 30).al and find the block of code that starts with the following:
//Unsupported feature: Code Modification on "OnOpenPage".

This is an example of where code was added to the OnOpenPage() trigger of the original page.

Any code modification to a trigger appears as an unsupported feature because it is seen as a modification to the base source code. Since we can access triggers in a page extension object though, this change is actually okay. We can keep our code in the OnOpenPage() trigger of the page extension and it will execute after the trigger on the original page executes.

  1. In Editor, add the following code to the page extension:
trigger OnOpenPage()
begin
MESSAGE('Remember to verify all fields when creating new items.');
end;

You can now delete the commented section of code for the unsupported feature.

  1. In Explorer, select Modification - Item Card(Page 30).al and find the block of code that starts with the following:
//Unsupported feature: Code Modification on "ItemsByLocation(Action 68).OnAction".

This is an example of where the original page action was changed to launch a custom page instead of the original base one. In this scenario, the easiest course of action is to disable the original action and replace it with our own action that calls the custom page.

  1. In Editor, add the following code in the actions section:
modify(ItemsByLocation)
{
ApplicationArea = Invalid;
Enabled = false;
Visible = false;
}
addafter(ItemsByLocation)
{
action(CustomItemsByLocation)
{
ApplicationArea = Location;
Caption = 'Items by Location';
AccessByPermission = TableData Location = R;
ToolTip = 'Show a list of items grouped by location.';
Image = ItemAvailbyLoc;

trigger OnAction()
begin
PAGE.RUN(PAGE::"Custom Items by Location", Rec);
end;
}
}
When you replace existing actions such as this, make sure that you set the actions properties to the same as the original action, so that it looks and feels the same to the user.

Notice that we set ApplicationArea = Invalid for the original control. It doesn't matter which ApplicationArea value you use but you should use one that won't appear anywhere in the system. This ensures that the control will never be seen by the users, even when performing the personalization feature.

You can delete the commented block of unsupported code.

  1. In Explorer, select Page 50000 - Custom Items by Location.al and find the following block of code:
[Scope('Internal')]

This is an example of where a base object was copied and then customized. When you convert these objects to AL, there are times when some of the original code/properties don't work within the AL environment because it's now being executed in an extension.

In this example, a function used within the Items by Location page was set to Internal, which means that the function could not be accessed from an extension. Now that we've copied the page into our extension, we no longer need that property as it actually stops our own extension from accessing the function.

  1. To address this, simply delete the following line of code:
[Scope('Internal')]
  1. We've now addressed all the conversion issues. You can use F5 to build and deploy the application and verify the changes.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset