function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jonathan Wolff 7Jonathan Wolff 7 

Get record Id from flow to apex class

Hello, I have now tried for some time to create a screen flow thatgets the campaign Id to set the campaign to completed and create a PDF and stores it in the Campaign files. The only problem I have is, that I do not know how to get the campaign Id into my apex Class Invocable Method. Could you tell me how to implement a InvocableVariable or something like that, so I can insert the record Id into the class?

The Apex class:
public class SerienbriefSpeichern{

@InvocableMethod(Label = 'Serienbrief' description='')  
public static void Serienbriefspeichern() {

     PageReference page = Page.Campaign_PDF;
     Blob contentBlob = !Test.isRunningTest() ? page.getContentAsPDF() : Blob.valueOf('Hardcoded sample text for Test class');
    ContentVersion cv = new ContentVersion();
    cv.VersionData = contentBlob;
    cv.Title = + '_' + + '_Serienbrief';
    cv.PathOnClient = + '_' + + 'Serienbrief.pdf';
    cv.Vertraulichkeitsstufe__c = 'Intern';
    cv.Dokumentenklasse__c ='Anderes Dokument (nicht aufbewahrungspflichtig)';
    insert cv;                
    cv = [SELECT Id, ContentDocumentId FROM ContentVersion WHERE Id = :cv.Id LIMIT 1];
    ContentDocumentLink cdl = new ContentDocumentLink();
    cdl.ContentDocumentId = cv.ContentDocumentId;
    cdl.ShareType = 'I';
    cdl.LinkedEntityId = '7017a000000pVQnAAM';
    insert cdl;

AnkaiahAnkaiah (Salesforce Developers) 
Hi Jonathan,

Can you refer the below article will help you to proceed further on your requirement.

If this information helpful, Please mark it as best answer.

Jonathan Wolff 7Jonathan Wolff 7
Hi Ankaiah,
so how would the List in List look like for getting the current campaign Id. I already created the Id as a variable and just want to pass it into the apex. Is this really required for my topic?