Only able to call Apex in Sandbox

edited February 23, 2018 in Questions
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:

image

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?

Comments

  • edited September 3, 2016
    Matti

    Try and reduce your URL to just /apex/SendMailsToParticipants


  • edited February 23, 2018
    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

    image
  • edited September 3, 2016
    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.

  • Zach McElrathZach McElrath Principal Software Engineer Chattanooga, TN 💎💎💎
    edited March 2, 2017
    Do Users in Production have access on their Profile / via assigned Permission Sets to your SendMailsToParticipants Apex Class?
  • edited June 2, 2017
    Any update on this I have the same issue?
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!