Comments (7)
Welcome! 👋
Thank you for posting this issue. 🙇🏼♂️ We will come back to you latest within the next 48h (working days). Stay tuned!
from apex-recipes.
@matej-me when I execute the query, as written, it works just fine for me. Can you help me understand a bit more about what issues you're having with the query as written?
from apex-recipes.
@codefriar Sure.
In the Custom Metadata Query about, this.objType is obtained by the call
Trigger.new[0].getSObjectType().getDescribe().getName();
Let's assume this is a custom object called Visit. The code above will return "Visit__c".
Now, let's run the following metadata query, assuming we have two metadata entries, one for a standard Contact object, another for the custom Visit object
SELECT Class__c, Object__c
FROM Metadata_Driven_Trigger__mdt
The result will be the following.
Class__c | Object__c |
---|---|
ContactTriggerHandler | Contact |
VisitTriggerHandler | 01I7a000000WWCg |
The query as is currently will be matching "Visit__c" against "01I7a000000WWCg", because the Custom Metadata Entity Relationship field does not return a string with the API Name of the object when referenced directly.
Let's now add Object__r.QualifiedApiName in the query
Class__c | Object__c | Object__r.QualifiedApiName |
---|---|---|
ContactTriggerHandler | Contact | Contact |
VisitTriggerHandler | 01I7a000000WWCg | Visit__c |
Basically, the query will return nothing, because it will be matching the wrong data. It won't find an entry for our Trigger Handler class.
from apex-recipes.
Ok, see this is where I'm confused. Here's a simplified query I'm testing with.
SELECT Class__c
FROM Metadata_Driven_Trigger__mdt
WHERE
Object__c = 'Account'
AND Enabled__c = TRUE
ORDER BY Execution_Order__c
I run this in an org where Apex Recipes is installed and it correctly returns two rows:
Here's the Log:
sfdx force:data:soql:query --query SELECT Class__c FROM Metadata_Driven_Trigger__mdt WHERE Object__c = 'Account' AND Enabled__c = TRUE ORDER BY Execution_Order__c
Querying Data... done
CLASS__C
──────────────────────────────
MDTAccountTriggerHandler
MDTSecondAccountTriggerHandler
Total number of records retrieved: 2.
I've not tried this with other objects, and I'm not opposed to your proposed change, I just want to make sure I understand the problem first and from my testing ... I don't see a problem.
from apex-recipes.
@codefriar Try adding a Metadata_Driven_Trigger__mdt record for a custom object. This will recreate the issue.
from apex-recipes.
from apex-recipes.
Not a problem. Hope to have been of service.
from apex-recipes.
Related Issues (20)
- RecipeTreeViewController not picking up new handlers HOT 3
- Database.enqueueBatch HOT 4
- Metadata Driven Trigger not working for custom objects. HOT 4
- Need to update the assert messages HOT 3
- Update LWC Jest and tests following wire protocol reform HOT 2
- Clicking "Make a suggestion on Github" button on the DMLRecipes Class Results in a 404 error HOT 14
- Reusable StripInaccessible Utility Class HOT 2
- Fundamentally the trigger framework is flawed HOT 18
- Email Recipe Updates HOT 2
- Data tree import fails with The requested resource does not exist in namespaced DE org HOT 2
- Regex too complicated error in developer edition HOT 2
- GitHub warning about bidirectional Unicode text HOT 2
- Username != user email in sandboxes HOT 8
- Document Viewer is not reloading HOT 3
- A slip error in the Log_Tests.cls HOT 2
- Homepage has an error in retrieving data if there are already apex classes in the org HOT 3
- Cannot deploy to a Trailhead Playground HOT 2
- Error retrieving data Regex too complicated HOT 4
- Logging Framework - Publish Immediate PE Limit not used HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from apex-recipes.