Hi guys
I have created a codeunit with subtype=Install. Its purpose is to create a couple of webservices and initialize Stripe data(for app monetization) on installation. But when I publish the app, neither does it create the web services nor does it initialize any data.
I have tried both (OnInstallAppPerCompany and OnInstallAppPerDatabase). Also tried to uninstall and unpublish app before publishing again but nothing seems to work. Is it something in the launch.json or app.json that's causing the issue?
Codeunit is given below. Thank you in advance :)
codeunit 500750 "App Installation"
{
Subtype = Install;
trigger OnInstallAppPerCompany()
begin
InitStripeData();
end;
trigger OnInstallAppPerDatabase();
var
myAppInfo: ModuleInfo;
begin
NavApp.GetCurrentModuleInfo(myAppInfo); // Get info about the currently executing module
if myAppInfo.DataVersion = Version.Create(0, 0, 0, 0) then // A 'DataVersion' of 0.0.0.0 indicates a 'fresh/new' install
PublishWebServices()
else
PublishWebServices();
end;
local procedure PublishWebServices()
var
WebServiceRec: Record "Web Service Aggregate";
begin
if not WebServiceRec.Get(WebServiceRec."Object Type"::Codeunit, 'DataExport') then begin
with WebServiceRec do begin
Init();
"Object Type" := "Object Type"::Codeunit;
"Object ID" := 70112322;
"Service Name" := 'DataExportCU';
Published := true;
end;
WebServiceRec.Insert(true);
end;
if not WebServiceRec.Get(WebServiceRec."Object Type"::Codeunit, 'ImportDataCU') then begin
with WebServiceRec do begin
Init();
"Object Type" := "Object Type"::Codeunit;
"Object ID" := 70112323;
"Service Name" := 'ImportData';
Published := true;
end;
WebServiceRec.Insert(true);
end;
end;
local procedure InitStripeData()
var
StripeSetup: Record "StripeSetup";
begin
StripeSetup.RefreshData();
end;
}