[Bug]: VsCodeIntegration create AppId Dependencie with Brackets
Describe the issue
- Open the "Extension Management" (Page 2500)
- Use Page Action "Show dependencies"
- Output in the Message: [ { "id": "{2461702A-1604-40AE-8F01-455922AECB26}", "name": "PartnerX WMS", "publisher": "PartnerX", "version": "1.0.0.0" } ] Problem: In the app.json the id does not match the pattern.
Expected behavior
The Output in the Message should be without the brackets: { "id": "2461702A-1604-40AE-8F01-455922AECB26", "name": "PartnerX WMS", "publisher": "PartnerX", "version": "1.0.0.0" }
I think that since we are in the context of the VSCode integration, the brackets should be removed during creation. It is also done in the implementation in the function FormatDependencyAsParameter.
Example:
[Scope('OnPrem')]
local procedure FormatDependencyAsParameter(var NavAppInstalledApp: Record "NAV App Installed App"): Text
var
AppVersion: Text;
DependencyFormatLbl: Label '%1,%2,%3,%4;', Comment = '%1 = Id, %2 = Name, %3 = Publisher, %4 = Version', Locked = true;
begin
// Skip System and Base app
case NavAppInstalledApp."App ID" of
SystemApplicationIdTxt, BaseApplicationIdTxt, ApplicationIdTxt:
exit('')
else
AppVersion := FormatDependencyVersion(NavAppInstalledApp."Version Major", NavAppInstalledApp."Version Minor", NavAppInstalledApp."Version Build", NavAppInstalledApp."Version Revision");
exit(StrSubstNo(DependencyFormatLbl, Format(NavAppInstalledApp."App ID", 0, 4), NavAppInstalledApp.Name, NavAppInstalledApp.Publisher, AppVersion)); // Format of GUID
end
Solution:
[Scope('OnPrem')]
local procedure FormatDependencyAsSerializedJsonObject(var PublishedApplication: Record "Published Application") Value: Text
var
AppId: Text;
AppVersion: Text;
Dependency: JsonObject;
begin
AppId := FormatDependencyGuidWithoutBrackets(PublishedApplication.ID); // New
Dependency.Add('id', AppId);
Dependency.Add('name', PublishedApplication.Name);
Dependency.Add('publisher', PublishedApplication.Publisher);
AppVersion := FormatDependencyVersion(PublishedApplication."Version Major", PublishedApplication."Version Minor", PublishedApplication."Version Build", PublishedApplication."Version Revision");
Dependency.Add('version', AppVersion);
Dependency.WriteTo(Value);
end;
[Scope('OnPrem')]
local procedure FormatDependencyGuidWithoutBrackets(Id: Guid): Text
begin
exit(Format(Id).TrimStart('{').TrimEnd('}'));
end;
Steps to reproduce
Show above.
Additional context
codeunit 8333 "VS Code Integration Impl."
I will provide a fix for a bug
- [x] I will provide a fix for a bug
@BB97GER - In the proposed solution, I would suggest instead using Format with format number = 4 to avoid the manual trimming. Also converting to lower case could be an additional improvement, since that is more VS Code / app.json standard.
@zeande - good hint
[Scope('OnPrem')]
local procedure FormatDependencyId(AppId: Guid): Text
begin
exit(LowerCase(Format(AppId, 0, 4));
end;