Only able to call Apex in Sandbox

  • 2
  • Question
  • Updated 1 year ago
  • (Edited)
Hello Everyone

I stumbled across a squite painful problem.
I built a skuidpage which calls a apex to send mails upon buttonclick. It all works perfectly fine in Sandbox, but we pushed it to a live org and it just plain out fails

i get this error in the console:



the Apex looks as follows:

public class SendMailsToParticipants{ 
@InvocableMethod   
static void SendMails(List<String> emails) {  
static void SendMails(List<String> emails) {  
        
        String eventId = recipients[0];
        Event e = [SELECT id FROM Event WHERE id = :eventId];
        
        recipients.remove(0);
        
        List<Messaging.SingleEmailMessage> mailList =  new List<Messaging.SingleEmailMessage>();
        
        for(String recipient : recipients){
            Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();mail.setTemplateId([select id from EmailTemplate where developername='EventUpdatedEmail'].id);mail.setTargetObjectId([SELECT id FROM User WHERE id = :recipient].id);mail.saveAsActivity = false;mail.setWhatId(e.id);mailList.add(mail);
        }
        
        Messaging.sendEmail(mailList); 
    }   
} String [] recipients = emails.get(0).split(',');

i can't figure out why its failing, the users have rights and i use the exat same data to test on live as on sandbox


Any ideas?
Photo of Matthias

Matthias

  • 628 Points 500 badge 2x thumb

Posted 2 years ago

  • 2
Photo of Gregg Baxter

Gregg Baxter

  • 80 Points 75 badge 2x thumb
Matti

Try and reduce your URL to just /apex/SendMailsToParticipants
Photo of Matthias

Matthias

  • 628 Points 500 badge 2x thumb
Thanks for the Idea Gregg, Unfortunely i can't alter the URL path. I call it as "Run Custom Apex Action".Therefore the URL gets built automatic

Photo of Gregg Baxter

Gregg Baxter

  • 80 Points 75 badge 2x thumb
Hi Matti

Log into the production Org and paste this into the URL: 
https://workbench.developerforce.com/login.php

This will tell you what you are getting.

It may be a compile error relating to that only top-level class methods can be declared static.

Try that and let me know.
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
Do Users in Production have access on their Profile / via assigned Permission Sets to your SendMailsToParticipants Apex Class?
Photo of Tami Lust

Tami Lust

  • 5,280 Points 5k badge 2x thumb
Any update on this I have the same issue?