-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add actionable errors for errors in the new No. Series module (#543)
In case that the user gets an error, we want to provide an easy way for the customer to fix those issues whenever possible. Hence adding some actionable errors to quickly resolve the issue. Fixes [AB#476365](https://dynamicssmb2.visualstudio.com/1fcb79e7-ab07-432a-a3c6-6cf5a88ba4a5/_workitems/edit/476365)
- Loading branch information
1 parent
016cf46
commit a51be6c
Showing
11 changed files
with
193 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
119 changes: 119 additions & 0 deletions
119
src/Business Foundation/App/NoSeries/src/Setup/NoSeriesErrorsImpl.Codeunit.al
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
// ------------------------------------------------------------------------------------------------ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. See License.txt in the project root for license information. | ||
// ------------------------------------------------------------------------------------------------ | ||
|
||
namespace Microsoft.Foundation.NoSeries; | ||
|
||
codeunit 323 "No. Series - Errors Impl." | ||
{ | ||
Access = Internal; | ||
InherentEntitlements = X; | ||
InherentPermissions = X; | ||
|
||
var | ||
OpenNoSeriesRelationshipsTxt: Label 'Open No. Series Relationships'; | ||
OpenNoSeriesLinesTxt: Label 'Open No. Series Lines'; | ||
OpenNoSeriesTxt: Label 'Open No. Series'; | ||
NoSeriesCodeTok: Label 'NoSeriesCode', Locked = true; | ||
|
||
procedure Throw(ErrorMessage: Text; NoSeriesLine: Record "No. Series Line"; ActionDictionary: Dictionary of [Text, Text]) | ||
var | ||
ErrorInfo: ErrorInfo; | ||
begin | ||
if UserCanEditNoSeries() then | ||
AddAction(ErrorInfo, NoSeriesLine.RecordId(), ActionDictionary); | ||
|
||
ErrorInfo.Message := ErrorMessage; | ||
Error(ErrorInfo); | ||
end; | ||
|
||
procedure Throw(ErrorMessage: Text; NoSeriesCode: Code[20]; ActionDictionary: Dictionary of [Text, Text]) | ||
var | ||
ErrorInfo: ErrorInfo; | ||
begin | ||
if UserCanEditNoSeries() then | ||
AddAction(ErrorInfo, NoSeriesCode, ActionDictionary); | ||
|
||
ErrorInfo.Message := ErrorMessage; | ||
Error(ErrorInfo); | ||
end; | ||
|
||
procedure OpenNoSeriesAction() ActionDictionary: Dictionary of [Text, Text] | ||
begin | ||
ActionDictionary.Add('Caption', OpenNoSeriesTxt); | ||
ActionDictionary.Add('Codeunit', format(Codeunit::"No. Series - Errors Impl.")); | ||
ActionDictionary.Add('MethodName', 'OpenNoSeries'); | ||
end; | ||
|
||
procedure OpenNoSeriesLinesAction() ActionDictionary: Dictionary of [Text, Text] | ||
begin | ||
ActionDictionary.Add('Caption', OpenNoSeriesLinesTxt); | ||
ActionDictionary.Add('Codeunit', format(Codeunit::"No. Series - Errors Impl.")); | ||
ActionDictionary.Add('MethodName', 'OpenNoSeriesLines'); | ||
end; | ||
|
||
procedure OpenNoSeriesRelationshipsAction() ActionDictionary: Dictionary of [Text, Text] | ||
begin | ||
ActionDictionary.Add('Caption', OpenNoSeriesRelationshipsTxt); | ||
ActionDictionary.Add('Codeunit', format(Codeunit::"No. Series - Errors Impl.")); | ||
ActionDictionary.Add('MethodName', 'OpenNoSeriesRelationships'); | ||
end; | ||
|
||
local procedure AddAction(var ErrorInfo: ErrorInfo; RecordId: RecordId; ActionDictionary: Dictionary of [Text, Text]) | ||
var | ||
CodeunitId: Integer; | ||
begin | ||
ErrorInfo.RecordId := RecordId; | ||
Evaluate(CodeunitId, ActionDictionary.Get('Codeunit')); | ||
ErrorInfo.AddAction(ActionDictionary.Get('Caption'), CodeunitId, ActionDictionary.Get('MethodName')); | ||
end; | ||
|
||
local procedure AddAction(var ErrorInfo: ErrorInfo; NoSeriesCode: Code[20]; ActionDictionary: Dictionary of [Text, Text]) | ||
var | ||
CodeunitId: Integer; | ||
begin | ||
ErrorInfo.CustomDimensions.Add(NoSeriesCodeTok, NoSeriesCode); | ||
Evaluate(CodeunitId, ActionDictionary.Get('Codeunit')); | ||
ErrorInfo.AddAction(ActionDictionary.Get('Caption'), CodeunitId, ActionDictionary.Get('MethodName')); | ||
end; | ||
|
||
procedure OpenNoSeriesRelationships(ErrorInfo: ErrorInfo) | ||
var | ||
NoSeriesLines: Record "No. Series Line"; | ||
begin | ||
NoSeriesLines.SetRange("Series Code", ErrorInfo.CustomDimensions.Get(NoSeriesCodeTok)); | ||
Page.Run(Page::"No. Series Relationships", NoSeriesLines); | ||
end; | ||
|
||
procedure OpenNoSeries(ErrorInfo: ErrorInfo) | ||
var | ||
NoSeries: Record "No. Series"; | ||
begin | ||
if ErrorInfo.CustomDimensions.Get(NoSeriesCodeTok) <> '' then | ||
NoSeries.SetRange(Code, ErrorInfo.CustomDimensions.Get(NoSeriesCodeTok)); | ||
Page.Run(Page::"No. Series", NoSeries); | ||
end; | ||
|
||
procedure OpenNoSeriesLines(ErrorInfo: ErrorInfo) | ||
var | ||
NoSeriesLines: Record "No. Series Line"; | ||
begin | ||
if ErrorInfo.CustomDimensions.ContainsKey(NoSeriesCodeTok) then | ||
NoSeriesLines.SetRange("Series Code", ErrorInfo.CustomDimensions.Get(NoSeriesCodeTok)) | ||
else | ||
if ErrorInfo.RecordId().TableNo = Database::"No. Series Line" then begin | ||
NoSeriesLines.Get(ErrorInfo.RecordId()); | ||
NoSeriesLines.SetRange("Series Code", NoSeriesLines."Series Code"); | ||
end; | ||
|
||
Page.Run(Page::"No. Series Lines", NoSeriesLines); | ||
end; | ||
|
||
local procedure UserCanEditNoSeries(): Boolean | ||
var | ||
NoSeries: Record "No. Series"; | ||
begin | ||
exit(NoSeries.WritePermission()); | ||
end; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"folders": [ | ||
{ | ||
"name": "Business Foundation", | ||
"path": "Business Foundation/App" | ||
}, | ||
{ | ||
"name": "Business Foundation Test Library", | ||
"path": "Business Foundation/Test Library" | ||
}, | ||
{ | ||
"name": "Business Foundation Tests", | ||
"path": "Business Foundation/Test" | ||
} | ||
] | ||
} |
Oops, something went wrong.