[SalesForce] Can Process Builder get the id of record that triggered the process

I have a process builder which invokes the Apex class. This Apex sends out an email to the Contact. The attachment of the Email is a VF page which gets the list of line items.

The issue here is that I would like to capture the record id of the record invoked by Process Builder and pass it on all the way to the VF page.

Any sample code or ideas would greatly help

 public SendEmailInvoice()

    {

    }
    public class MyInvocableVariable {
    @InvocableVariable(label='Id' required=true)
    public Id recId;

    }    
   @InvocableMethod(label='Send an email from apex class'
 description='sends an email')

    public static void send()

    {
        List<MyInvocableVariable> myInvocableVariableList = new List<MyInvocableVariable>();
 for(MyInvocableVariable myInvocableVariable : myInvocableVariableList) {


       system.debug('recId=' + myInvocableVariable.recId);
 }
                 // Define the email
        Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();

        PageReference pdf = Page.SendInv;

        pdf.setRedirect(true);

        // Take the PDF content
        Blob b = pdf.getContent();
 List<String> mail = new List<String>();
        mail.add('test@test.com');
        // Create the email attachment
        Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
        efa.setFileName('Attachement');
        efa.setBody(b);

        // Sets the paramaters of the email
        email.setSubject('Testing');
        email.setToAddresses(mail);

        email.setPlainTextBody('Test');

        email.setFileAttachments(new Messaging.EmailFileAttachment[] {efa}); // Sends the email

        Messaging.SendEmailResult [] r =

            Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});  


    }

Best Answer

Don't get confused.. as glls said, it's pretty straightforward...all you need it a recId.

public static void send(List<Id> ids).. 

create a List argument in the function to get the recIds.. then to You process builder and assign the ID to recordId or Id You want to set... where You are calling this function.

You can see, I have a process builder on Account, an action that always run. and not I am getting the method agreement i.e ids with the AccountId..

enter image description here