You need to sign in to do that
Don't have an account?
class/trigger
Hello everyone,
I'm completely new to apex, I didn't do any Java development before, and I have almost zero experience with object-oriented programming. So, during an excercise within salesforce I encountered a problem: I want to use a function of a class that I have written here:
public class InvitationSender { public void sendInvitation(Invitations__c invitation) { [lots of code] } }
Now, what I want to do is to use that sendInvitation function when a record within my invitations__c object is inserted. So I use this code:
trigger SendEmailInvitation on Invitations__c (after insert) { InvitationSender.sendInvitation[] invitation = new InvitationSender.sendInvitation(); InvitationSender.sendInvitation(invitation); }
...And the Force.com IDE just says "Save error: invalid type: InvitationSender.sendInvitation.
Can anyone help me out on this? I know this might be a stupid question, but I am really inexperienced, so please be kind ;-).
All Answers
You are trying to instantiate the method rather than the class. You should just instantiate the class and call the method. Also, your method looks like it only takes a single instance of invitation __c - you should probably make this accept an array, otherwise you will have to iterate the trigger records. The code below assumes it can take a list of records:
If it can't, you'll need something like the following, but this probably won't scale:
For a better understanding, I'll just post the whole sendInvitation-Code here. It's commentated, and since it's beginner's code, it should not be hard to understand:
At what point can I make this method accept an array?