"Fetcher" patter #147
mazhelez
started this conversation in
BC Patterns
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey AL devs!
I have been working on extracting and defining a pattern that could be useful in several cases. I call it "Fetcher" pattern. Please read on and share your feedback.
Fetcher patter
Description
Fill-in data for internal table from one or more apps without exposing the table.
The pattern works for other cases as well. Doesn't have to be an internal table that needs to be filled in.
Outline
OnFetchData()
that includes the publisher and a publicAddData
procedure.FetchData()
called when data needs to be fetched.Definition
Usage
Fetcher.FetchData()
when you need to populate the data.OnFetchData
and callingAddData
.Advantages
Consider the need to import data only through certain extensions:
or
Examples
System Application:
Telemetry Loggers
This is an example where the fetcher doesn't need to be populating data.
Register
is used asAddData
andOnRegisterTelemetryLogger
is used forOnFetchData()
.In that example the "Fetcher" codeunit even has a state (
CurrentPublisher
) which comes to show how powerful the pattern can be. State in this case is used to fetch the telemetry logger defined for the publisher who calls the procedure.Default Permission Set in Plan
Classic example of the Fetcher pattern.
In this case, another useful aspect is shown:
OnFetchData
can come with parameters (OnGetDefaultPermissions(PlanId: Guid)
).The parameter in this case is used to get the default permissions only for a certain plan.
Beta Was this translation helpful? Give feedback.
All reactions