• jacab smith
  • NEWBIE
  • 0 Points
  • Member since 2022

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies

Hello, 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:

User-added imageinvocable 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 code for the VF Page Controller:
 
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! 
Hi, I wrote a trigger and a test class, but when testing I get below error: 

System.DmlException: Update failed. First exception on row 0 with id 003M000000Zc1NaIAJ; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, PopulateContactAreaCode: execution of BeforeUpdate
caused by: System.NullPointerException: Attempt to de-reference a null object
Trigger.PopulateContactAreaCode: line 5, column 1: []

Trigger:
trigger PopulateContactAreaCode on Contact (before insert, before update) {

    for(Contact contact : Trigger.new)
    {
        string AreaCode = CountryRegion__c.getInstance(contact.MailingCountry).Area_Code__c;
        contact.Area_Code__c = AreaCode;
    }
}

test class:
@isTest
public class PopulateContactAreaCodeTest
{
    static testMethod void attTriggerTest1()
    {
        test.startTest();
        Account acct = new Account(id = '001M000000iLhTL', Name = 'Test Account ', Mailing_Country__c = 'Afghanistan');
        update acct;      
        Contact con = new Contact(id = '003M000000Zc1Na', LastName = 'Test Contact', Account = acct, Email = 'test@test.com', Mailing_Country__c = 'Afghanistan', MailingCountry = 'Afghanistan');
        update con;
        delete con;
        test.stopTest();
    }
}

any idea what I added wrong?

thank you in advance
  • February 24, 2015
  • Like
  • 2