InvocableMethod Through anonymous APEX
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.
Example:
@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>();
l.add(cr);
SL_Mapping_Handler.generateAndInsertAllRecords(l);
But I get an error:
Line: 3, Column: 1 Invalid type: ContextRecord
Is this possible to do? Is it just a syntax error?
apex invocable-method
add a comment |
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.
Example:
@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>();
l.add(cr);
SL_Mapping_Handler.generateAndInsertAllRecords(l);
But I get an error:
Line: 3, Column: 1 Invalid type: ContextRecord
Is this possible to do? Is it just a syntax error?
apex invocable-method
add a comment |
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.
Example:
@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>();
l.add(cr);
SL_Mapping_Handler.generateAndInsertAllRecords(l);
But I get an error:
Line: 3, Column: 1 Invalid type: ContextRecord
Is this possible to do? Is it just a syntax error?
apex invocable-method
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.
Example:
@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>();
l.add(cr);
SL_Mapping_Handler.generateAndInsertAllRecords(l);
But I get an error:
Line: 3, Column: 1 Invalid type: ContextRecord
Is this possible to do? Is it just a syntax error?
apex invocable-method
apex invocable-method
edited 11 hours ago
Adrian Larson♦
108k19115243
108k19115243
asked 11 hours ago
Dan WoodingDan Wooding
1,9671137
1,9671137
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You will need to declare the list in your snippet as:
List<SL_Mapping_Handler.ContextRecord> l = new List<SL_Mapping_Handler.ContextRecord>();
Replaces:
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 insideSL_Mapping_Handler
, you need to prepend the name of the outer class to be able to use the inner class.
– Derek F
11 hours ago
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "459"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f250225%2finvocablemethod-through-anonymous-apex%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You will need to declare the list in your snippet as:
List<SL_Mapping_Handler.ContextRecord> l = new List<SL_Mapping_Handler.ContextRecord>();
Replaces:
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 insideSL_Mapping_Handler
, you need to prepend the name of the outer class to be able to use the inner class.
– Derek F
11 hours ago
add a comment |
You will need to declare the list in your snippet as:
List<SL_Mapping_Handler.ContextRecord> l = new List<SL_Mapping_Handler.ContextRecord>();
Replaces:
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 insideSL_Mapping_Handler
, you need to prepend the name of the outer class to be able to use the inner class.
– Derek F
11 hours ago
add a comment |
You will need to declare the list in your snippet as:
List<SL_Mapping_Handler.ContextRecord> l = new List<SL_Mapping_Handler.ContextRecord>();
Replaces:
List<ContextRecord> l = new List<ContextRecord>();
You will need to declare the list in your snippet as:
List<SL_Mapping_Handler.ContextRecord> l = new List<SL_Mapping_Handler.ContextRecord>();
Replaces:
List<ContextRecord> l = new List<ContextRecord>();
edited 11 hours ago
Daniel Ballinger
73k15149394
73k15149394
answered 11 hours ago
Jayant DasJayant Das
14.3k2824
14.3k2824
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 insideSL_Mapping_Handler
, you need to prepend the name of the outer class to be able to use the inner class.
– Derek F
11 hours ago
add a comment |
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 insideSL_Mapping_Handler
, you need to prepend the name of the outer class to be able to use the inner class.
– Derek F
11 hours ago
1
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
11 hours ago
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
11 hours ago
add a comment |
Thanks for contributing an answer to Salesforce Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f250225%2finvocablemethod-through-anonymous-apex%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown