0

I am using an invocable method along with a controller to feed a list of records being returned from the flow and invocable method, into a VF Page in order to render multiple records with the field values as a PDF. When I try to save my new Visual Force page pointing to my controller class I get this error:

enter image description here

telling me a variable and method I am using in my invocable method are unknown properties.

I'm not sure why they are "unknown," and what I can do to make them "known."

Does anyone know how to work through this blocker?

Here is the VF page code:

    <apex:page controller="PackingListQueryController" renderAs="pdf" showHeader="false" sidebar="false" standardStylesheets="false" applyBodyTag="false" applyHtmlTag="false">
<apex:repeat value = "{! FilteredIntakes}" var = "oneItem">
    <html>
    <head>
        <style>
            @page {
                size: letter;
                margin: 25mm;
                @top-center {
                    content: "{! oneItem.name }";
                }
                @bottom-center {
                    content: "Page " counter(page) " of " counter(pages);
                }
            }
            .page-break {
                display:block;
                page-break-after:always;
            }
            body {
                font-family: Arial Unicode MS;
            }
        </style>
    </head>
    <body>
        <apex:pageBlock title="Intake Details">
        <apex:pageBlockSection >
        <table width="100%" border="1" cellspacing="0" cellpadding="5" class="print-friendly">
                        <tr>
                            <th>Parent Name</th>
                            <th>Household</th>
                            <th>Delivery Type</th>
                            <th>Delivery Date</th>
                            <th>Delivery Time</th>
                            <th>Intake Status</th>
                        </tr>
                        <tr>
                                <th>{! Intake__c.Parent_Name__c }</th>
                                <td class="tableContent">{! oneItem.Household__c }</td>
                                <td class="tableContent">{! oneItem.Priority__c }</td>
                                <td class="tableContent">{! oneItem.Delivery_Date__c }</td>
                                <td class="tableContent">{! oneItem.Delivery_Time__c }</td>
                                <td class="tableContent">{! oneItem.Intake_Status__c }</td>
                            </tr>
            </table>
    </apex:pageBlockSection>
    </apex:pageBlock>
    <apex:pageBlock title="Intake Details">
    <apex:pageBlockSection >
        <apex:outputField value="{! oneItem.Parent_Name__c }"/>
        <apex:outputField value="{! oneItem.Household__c }"/>
        <apex:outputField value="{! oneItem.Priority__c }"/>
        <apex:outputField value="{! oneItem.Delivery_Date__c }"/>
        <apex:outputField value="{! oneItem.Delivery_Time__c }"/>
        <apex:outputField value="{! oneItem.Intake_Status__c }"/>
    </apex:pageBlockSection>
    </apex:pageBlock>
    <apex:pageBlock title="Baby Wipes and Formula">
    <apex:pageBlockTable value="{!oneItem}" var="Baby Wipes and Formula">
       <apex:column value="{!oneItem.Baby_Wipes_Num__c}"/>
       <apex:column value="{!oneItem.Baby_Formula_Num__c}"/>
       <apex:column value="{!oneItem.Formula_Type__c}"/>
    </apex:pageBlockTable>
</apex:pageBlock>
    <apex:pageBlock title="Diaper Boxes">
    <apex:pageBlockTable value="{!Intake__c}" var="Diaper Boxes">
       <apex:column value="{!oneItem.Diaper_Boxes_Newborn__c}"/>
       <apex:column value="{!oneItem.Diaper_Boxes_Size_1__c}"/>
       <apex:column value="{!oneItem.Diaper_Boxes_Size_2__c}"/>
       <apex:column value="{!oneItem.Diaper_Boxes_Size_3__c}"/>
       <apex:column value="{!oneItem.Diaper_Boxes_Size_4__c}"/>
       <apex:column value="{!oneItem.Diaper_Boxes_Size_5__c}"/>
       <apex:column value="{!oneItem.Diaper_Boxes_Size_6__c}"/>
       <apex:column value="{!oneItem.Diaper_Boxes_Size_7__c}"/>
    </apex:pageBlockTable>
    </apex:pageBlock>
    <apex:pageBlock title="Pull Ups">
    <apex:pageBlockTable value="{!oneItem}" var="Pull-up Boxes Boys">
       <apex:column value="{!oneItem.Pull_Ups_Boys_Size_2T_3T__c}"/>
       <apex:column value="{!oneItem.Pull_Ups_Boys_Size_3T_4T__c}"/>
       <apex:column value="{!oneItem.Pull_Ups_Boys_Size_4T_5T__c}"/>
       <apex:column value="{!oneItem.Pull_Ups_Girls_Size_2T_3T__c}"/>
       <apex:column value="{!oneItem.Pull_Ups_Girls_Size_3T_4T__c}"/>
       <apex:column value="{!oneItem.Pull_Ups_Girls_Size_4T_5T__c}"/>
    </apex:pageBlockTable>
    </apex:pageBlock>
    </body>
   </html>
</apex:repeat>
</apex:page>

Here is the VF page controller class code:

 public with sharing class PackingListQueryController {
    //properties used to pass data between VF page and the savepdf method 
    public List<Intake__c> filteredIntakes = new List<Intake__c>();
    //intake Intake_Status__c = "Approved" & Partner_Intake__c = TRUE
    @InvocableMethod(label='Get Filtered Intake Records' description='Get filtered intake records from yields of the flow, filter them again, and return the remaining records')
    public static List<Intake__c> getIntakes(List<Request> params){
        List<Intake__c> filteredIntakes = new List<Intake__c>();
        Date filterStartDate;
        Date filterEndDate;
        String filterCity;
        Integer i = 0;
        //[[{startDeliverDate: 2022-01-01, endDeliveryDate: 2022-01-10, city: null}]]
        filterStartDate = params[0].startDeliveryDate;        
        System.debug('Filtered Start Date: ' + filterStartDate);        
        filterEndDate = params[0].endDeliveryDate;
        System.debug('Filtered Info: ' + params[0]); 
        // filterStartDate = Date.newInstance(paramStartDate.year(), paramStartDate.Month(), paramStartDate.Day());
        // filterEndDate = Date.newInstance(paramEndDate.year(), paramEndDate.Month(), paramEndDate.Day());
        filterCity = params[0].city;
        if(String.isNotBlank(filterCity)){
            filteredIntakes = [SELECT Id, Name, Street_Address__c, City__c, State__c, Zip_Code__c, Priority__c, Number_of_Families_Served__c, Number_of_Children_Served__c, 
                                 New_Families__c, Diaper_Boxes_Newborn__c, Diaper_Boxes_Size_1__c, Diaper_Boxes_Size_2__c, Diaper_Boxes_Size_3__c, Diaper_Boxes_Size_4__c, 
                                 Diaper_Boxes_Size_5__c, Diaper_Boxes_Size_6__c, Diaper_Boxes_Size_7__c, Pull_Ups_Boys_Size_2T_3T__c, Pull_Ups_Boys_Size_3T_4T__c, Pull_Ups_Boys_Size_4T_5T__c,
                                 Pull_Ups_Girls_Size_2T_3T__c, Pull_Ups_Girls_Size_3T_4T__c, Pull_Ups_Girls_Size_4T_5T__c
                                 FROM Intake__c
                                 WHERE Intake_Status__c = 'Approved' AND Partner_Intake__c = TRUE
                                 AND Delivery_Date__c >= :filterStartDate AND Delivery_Date__c <= :filterEndDate
                                 AND Priority__c = :filterCity LIMIT 10];
        } else {
            filteredIntakes = [SELECT Id, Name, Street_Address__c, City__c, State__c, Zip_Code__c, Priority__c, Number_of_Families_Served__c, Number_of_Children_Served__c, 
                                New_Families__c, Diaper_Boxes_Newborn__c, Diaper_Boxes_Size_1__c, Diaper_Boxes_Size_2__c, Diaper_Boxes_Size_3__c, Diaper_Boxes_Size_4__c, 
                                Diaper_Boxes_Size_5__c, Diaper_Boxes_Size_6__c, Diaper_Boxes_Size_7__c, Pull_Ups_Boys_Size_2T_3T__c, Pull_Ups_Boys_Size_3T_4T__c, Pull_Ups_Boys_Size_4T_5T__c,
                                Pull_Ups_Girls_Size_2T_3T__c, Pull_Ups_Girls_Size_3T_4T__c, Pull_Ups_Girls_Size_4T_5T__c
                                FROM Intake__c
                                WHERE Intake_Status__c = 'Approved' AND Partner_Intake__c = TRUE
                                AND Delivery_Date__c >= :filterStartDate AND Delivery_Date__c <= :filterEndDate LIMIT 10];
        }
        for (Intake__c intake : filteredIntakes) {
            System.debug('Filtered Intake Id: ' + intake.Id);
        }
        // for (intakeList < filteredIntakes.length(); i++){
        //     System.debug('Filtered Intake Id: ' + filteredIntakes[i].Id);
        // }
        System.debug('Count Record: ' + filteredIntakes.size());
        getFilteredIntakes(filteredIntakes);
        return filteredIntakes;
    }
    public static List<Intake__c> getFilteredIntakes(List<Intake__c> intakeRecords) {
        return intakeRecords;
    }
    //Inner class to store additional params to be stored in a list 'Request'
    public class Request {
        @InvocableVariable(label='Starting Delivery Date' required='true' description='Starting Delivery Date')
        public Date startDeliveryDate;
        @InvocableVariable(label='Ending Delivery Date' required='true' description='Ending Delivery Date')
        public Date endDeliveryDate;
        @InvocableVariable(label='City' description='City')
        public String city;
    }
    public class Response {
        @InvocableVariable(label='Success' description='Successful execution of batch job' required=true)
        public Boolean success = true;
        }
}

Any help would be most appreciated. Thank you!
0

1 Answer 1

0

See Apex Controllers: What do the get; set; do?.

So:

public List<Intake__c> filteredIntakes {get; set;}

But you also need to make sure that the list s populated for the Visualforce case. One way to do that would be:

public List<Intake__c> filteredIntakes {
    get {
        if (filteredIntakes == null) {
            filteredIntakes = ...
        }
        return filteredIntakes;
    }
    set;
}

where you need to replace the ... with a method that creates and populates the list.

1
  • Thank you! Would I populate the list inside or outside of my invocable method?
    – user117449
    Dec 24, 2022 at 16:45

You must log in to answer this question.