Skip to content
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

Implementing New Plugin but Unable to Get the Triggered Data #778

Open
JiradaWi opened this issue Oct 11, 2024 · 4 comments
Open

Implementing New Plugin but Unable to Get the Triggered Data #778

JiradaWi opened this issue Oct 11, 2024 · 4 comments
Assignees
Labels
Feature: Plugin Framework Items related to Nebula Logger's plugin framework Type: Bug Something isn't working

Comments

@JiradaWi
Copy link
Contributor

Package Edition of Nebula Logger

Unlocked Package

Package Version of Nebula Logger

v4.14.12

New Bug Summary

I am trying to implement email notification when Log__c is created, so I am trying to use Flow plugin using the following document:
image

First, I create the following custom metadata.
image

Secondly, I created flow with the following parameter
image
image

But triggerNew value is always empty.
image


I already tried Apex plugin, but i cannot save the apex class even if I use the example class provided in your wiki.
image
image

@JiradaWi JiradaWi added the Type: Bug Something isn't working label Oct 11, 2024
@jongpie
Copy link
Owner

jongpie commented Oct 14, 2024

Hi @JiradaWi thanks for reporting this!

For Flow: I think your setup looks correct, this does seem to be a bug with data not being correctly passed to the Flow plugins. I'll see if I can fix it this week.

For Apex: That doc page in the wiki for the Apex plugin is incredibly out of date - they refer to the old, first version of the plugin framework that no longer exists. v2 of the plugin framework was released in v4.7.1, about 2+ years ago. Sooo... that page is... very behind 😨 I'll work on updating + expanding the wiki content for plugins to reflect the current implementation.

In the meantime, here's an updated example that you can use for an Apex plugin

public class ExampleTriggerablePlugin implements LoggerPlugin.Triggerable {
  public void execute(LoggerPlugin__mdt configuration, LoggerTriggerableContext input) {
    // Example: only run the plugin for Log__c records
    if (context.sobjectType != Schema.Log__c.SObjectType) {
      return;
    }
    
    List<Log__c> logs = (List<Log__c>) input.triggerNew;
    switch on input.triggerOperationType {
      when BEFORE_INSERT {
        for (Log__c log : logs) {
          log.Status__c = 'On Hold';
        }
      }
      when BEFORE_UPDATE{
        // TODO add before-update logic
      }
    }
  }
}

@jongpie jongpie added the Feature: Plugin Framework Items related to Nebula Logger's plugin framework label Oct 14, 2024
@jongpie jongpie self-assigned this Oct 14, 2024
@jongpie
Copy link
Owner

jongpie commented Oct 16, 2024

@JiradaWi I had some time earlier today to review the Flow plugin issues with @jamessimone , and from what we saw, I think fixing the issues will be a bit more involved than I originally anticipated. Some of the design of how Flow plugins are built will need to be changed, and I'll need to do some extra tinkering to figure out the best way to move forward. My hope is to continue working on it some over the coming weeks/months, but I don't have an exact timeline on when I'll have a fix ready for Flow plugins.

In the meantime, Apex plugins should work - if that's an option for you to use for now, let me know if you have any other questions about how to implement it that way.

@JiradaWi
Copy link
Contributor Author

@jongpie Now I decided to use Apex class to send out email notification. It working as expected now. We already pushed it to UAT. Thank you for the answer!

@jongpie
Copy link
Owner

jongpie commented Oct 16, 2024

That's great, glad to hear it! I'll keep this issue open to track progress on fixing Flow plugins, but I'm really glad to hear that you've already been able to move on to UAT with an Apex plugin 🥳

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature: Plugin Framework Items related to Nebula Logger's plugin framework Type: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants