-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Selector Layer / question about injecting method or criterias #71
Comments
G'day @alanjaouen. Thanks for reaching out. A couple of questions for you
Based on what I have heard you describe, it sounds like a good candidate for the AT4DX feature "Selector Method Injection", but let me know the answers to questions above and we can go from there. |
Hi @ImJohnMDaniel , Thanks for your quick reply on this,
I based my implementation on the wiki, and these videos:
I will have a look at "Architectural Considerations to Implementing DX and 2nd Generation Packaging"
PackageA is in common layer.
I searched for this particular feature (before creating this issue), but didn't found anything online, is there any centralized documentation that reference this feature? Thanks |
Ok. If PackageA is a common layer package then you are good. There are two things that you are trying to do:
Referenced examples are found in the AT4DX Sample Code repo. Add a new field form PackageB to the PackageA.AccountsSelector -- "Selector Field Injection"Selector Field Injection allows you to setup a field set in PackageB, and then include this new field that is only present in PackageB -- In the AT4DX Sample Code repo, there is a new "Slogan" field added to the Account Sobject (e.g. equivalent to your PackageB Add a new method to the PackageA.AccountsSelector that queries by this new PackageB field. -- "Selector Method Injection"Selector Method Injection allows you to write a distinct class for this new method and, when the selector is called, this method class will be injected into the base selector class and operate as if it were simply a method that is directly part of the class itself. In the AT4DX Sample Code, we had a need to query for Accounts where the Slogan field matched a specific string set. Obviously, since the Slogan field is not part of the base package (in your case, PackageA), we could not add the method directly to the AccountsSelector in PackageA. Instead, the "SelectBySloganSelectorMethod" class was created. This Selector Method class extends the The only difference from a normal selector method is around the question of "how to pass parameters to the query class?" To do that, you define an inner class -- typically named "Parameters" -- that implements You can see an example of how this Selector Method is called in the
And the Selector Method is combined with the base AccountsSelector by using the
Hopefully this addresses your question. Let me know if something is still not clear or if I am not understanding your question correctly. Hope this helps! Cheers! |
Thanks for your complete anwer, it will definitly help me 👍 |
Hi @ImJohnMDaniel @stohn777 ,
I'm starting to implement AT4DX in my company, and this framework help us a lot for switching to unlocked package, so first of all thank you for sharing this with us.
I'm wondering about a use case for splitting my monolithic code in package:
Let's says that:
PackageA
defineAccountSelector
PackageB
define a fieldpackageB_id__c
onAccount
I would like to define in
packageB
a methode likeAccountSelector.getAccountByPackageB_id__c(Set<String>)
I did not find any exemple about this use case, should I create an AccountSelector specifically for
PackageB
?Thanks for your time,
Best
Alan
The text was updated successfully, but these errors were encountered: