Giter VIP home page Giter VIP logo

Comments (7)

github-actions avatar github-actions commented on August 23, 2024

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.

codefriar avatar codefriar commented on August 23, 2024

@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.

matej-me avatar matej-me commented on August 23, 2024

@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.

codefriar avatar codefriar commented on August 23, 2024

@matej-me

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.

matej-me avatar matej-me commented on August 23, 2024

@codefriar Try adding a Metadata_Driven_Trigger__mdt record for a custom object. This will recreate the issue.

from apex-recipes.

codefriar avatar codefriar commented on August 23, 2024

from apex-recipes.

matej-me avatar matej-me commented on August 23, 2024

Not a problem. Hope to have been of service.

from apex-recipes.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.