I was looking into a customer App yesterday. That app had a dependency defined in app.json.

I wanted to look at the real requirements for this dependency. I found 1 (one) place in my code where this dependent App was used.
dataitem(PageLoop; "Integer")
{
DataItemTableView = SORTING (Number) WHERE (Number = CONST (1));
column(Phone_No_Cust; Cust."Phone No.")
{
}
column(Registration_No_Cust; Cust."ADV Registration No.")
{
}
column(CompanyInfo_Picture; CompanyInfo.Picture)
{
}
In Iceland we add a field to the Customer table (Cust.”ADV Registration No.”). Every business entity in Iceland has a registration number. A company only has one registration number but can have multiple VAT numbers. We already have that registration number field in the Company Information record, but we also add it to Customer, Vendor and Contact records. The Employee social security number equals to the registration number for an individual.
To be able to remove the compile dependency, and therefore the installation dependency I did the following:
Removed the dependency App from app.json
Added a variable to the report
var
ADVRegistrationNo: Text;
Changed the data set configuration to use this variable
dataitem(PageLoop; "Integer")
{
DataItemTableView = SORTING (Number) WHERE (Number = CONST (1));
column(Phone_No_Cust; Cust."Phone No.")
{
}
column(Registration_No_Cust; ADVRegistrationNo)
{
}
column(CompanyInfo_Picture; CompanyInfo.Picture)
{
}
Located the code that fetches the Customer record and added the reference way to get the required data
trigger OnAfterGetRecord()
var
DataTypeMgt: Codeunit "Data Type Management";
RecRef: RecordRef;
FldRef: FieldRef;
begin
Cust.Get("Ship-to Customer No.");
RecRef.GetTable(Cust);
if DataTypeMgt.FindFieldByName(RecRef, FldRef, 'ADV Registration No.') then
ADVRegistrationNo := FldRef.Value();
end;
There are both positive and negative repercussion of these changes.
The positive is that we can now install, uninstall both apps without worrying about the compile dependency.
The negative is that breaking changes to the dependent App does not break the installation of this customer App.
So, what happens if the dependent App is not installed? The FindFieldByName will return false and the variable will be blank text.
Since we have adapted the policy that Microsoft uses; no breaking table changes, this field should just be there.
If the data is required and will break the functionality if not present we can change the code to something like this.
Cust.Get("Ship-to Customer No.");
RecRef.GetTable(Cust);
if DataTypeMgt.FindFieldByName(RecRef, FldRef, 'ADV Registration No.') then
ADVRegistrationNo := FldRef.Value()
else
Error('Please install the Advania IS Localization App into this Tenant!')