I have an invocablemethod that runs from a process builder that got broken for a few months I had a mapping issue and some fields didn't populate or create for various reasons. In the process builder you only need to pass the Opportunity Id and a string variable and it does the work.

I want to fix my error and pass in Opportunity Ids directly to the method however, I can't figure out how to populate the data to do it.


@InvocableMethod(label='Perform Mapping' description='Performs a ConvertAnything mapping given a list of records.')
global static void generateAndInsertAllRecords(List<ContextRecord> contextRecords)
   // do stuff

ContextRecord is defined here:

global class SL_Mapping_Handler extends SL_Mapping_Handler_Helper {

// used for determining which records to perform the mapping from
global class ContextRecord {
    @InvocableVariable(label='Id' required=true)
    global Id Id;
    @InvocableVariable(label='Custom Mapping Identifier')
    global String customMappingIdentifier;

I'm in anon apex trying to do something like this:

SL_Mapping_Handler.ContextRecord cr = new SL_MApping_Handler.ContextRecord();
cr.Id = '006A000000YN0gd';
cr.customMappingIdentifier = 'Opp Auto Renewal';

List<ContextRecord> l = new List<ContextRecord>();

But I get an error:

Line: 3, Column: 1 Invalid type: ContextRecord

Is this possible to do? Is it just a syntax error?


1 Answer 1


You will need to declare the list in your snippet as:

List<SL_Mapping_Handler.ContextRecord> l = new List<SL_Mapping_Handler.ContextRecord>();


List<ContextRecord> l = new List<ContextRecord>();
  • 1
    Beat me to it. The issue was that OP was trying to reference an inner class outside of its containing class. Unless you're inside SL_Mapping_Handler, you need to prepend the name of the outer class to be able to use the inner class.
    – Derek F
    Feb 13, 2019 at 19:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.