Create List of Strings from Another List of Object Records
I am new to Salesforce development and I am trying to practice by creating a list of strings deriving from another list of object records created from a query. My code is the following....
public class ProjectStatus{
public static void Test(List<String> myArray) {
for (List<pse__Proj__c> projects : [SELECT Id FROM pse__Proj__c WHERE Project_Status_Requirement__c = True LIMIT 1000]) {
myArray.add(String.valueOf(projects));
}
System.debug(myArray);
}
}
After attempting to run in the Anon window, I receive the following error...
Method does not exist or incorrect signature: void Test() from the type ProjectStatus
I ran the following code in the Anon Exec window...
ProjectStatus.Test();
Could anyone help me identify why this error is being thrown? This is probably a simple beginner's mistake but after spending a lot of time researching and editing my code I am still unsuccessful so I am hoping someone here may be able to add some input, thanks in advance!
apex list developer-console developer
New contributor
add a comment |
I am new to Salesforce development and I am trying to practice by creating a list of strings deriving from another list of object records created from a query. My code is the following....
public class ProjectStatus{
public static void Test(List<String> myArray) {
for (List<pse__Proj__c> projects : [SELECT Id FROM pse__Proj__c WHERE Project_Status_Requirement__c = True LIMIT 1000]) {
myArray.add(String.valueOf(projects));
}
System.debug(myArray);
}
}
After attempting to run in the Anon window, I receive the following error...
Method does not exist or incorrect signature: void Test() from the type ProjectStatus
I ran the following code in the Anon Exec window...
ProjectStatus.Test();
Could anyone help me identify why this error is being thrown? This is probably a simple beginner's mistake but after spending a lot of time researching and editing my code I am still unsuccessful so I am hoping someone here may be able to add some input, thanks in advance!
apex list developer-console developer
New contributor
2
What was your exec anon code? Could you edit the code in to your question?
– sfdcfox
3 hours ago
@sfdcfox updated the post, but here is the code I ran... ProjectStatus.Test();
– Max Goldfarb
3 hours ago
add a comment |
I am new to Salesforce development and I am trying to practice by creating a list of strings deriving from another list of object records created from a query. My code is the following....
public class ProjectStatus{
public static void Test(List<String> myArray) {
for (List<pse__Proj__c> projects : [SELECT Id FROM pse__Proj__c WHERE Project_Status_Requirement__c = True LIMIT 1000]) {
myArray.add(String.valueOf(projects));
}
System.debug(myArray);
}
}
After attempting to run in the Anon window, I receive the following error...
Method does not exist or incorrect signature: void Test() from the type ProjectStatus
I ran the following code in the Anon Exec window...
ProjectStatus.Test();
Could anyone help me identify why this error is being thrown? This is probably a simple beginner's mistake but after spending a lot of time researching and editing my code I am still unsuccessful so I am hoping someone here may be able to add some input, thanks in advance!
apex list developer-console developer
New contributor
I am new to Salesforce development and I am trying to practice by creating a list of strings deriving from another list of object records created from a query. My code is the following....
public class ProjectStatus{
public static void Test(List<String> myArray) {
for (List<pse__Proj__c> projects : [SELECT Id FROM pse__Proj__c WHERE Project_Status_Requirement__c = True LIMIT 1000]) {
myArray.add(String.valueOf(projects));
}
System.debug(myArray);
}
}
After attempting to run in the Anon window, I receive the following error...
Method does not exist or incorrect signature: void Test() from the type ProjectStatus
I ran the following code in the Anon Exec window...
ProjectStatus.Test();
Could anyone help me identify why this error is being thrown? This is probably a simple beginner's mistake but after spending a lot of time researching and editing my code I am still unsuccessful so I am hoping someone here may be able to add some input, thanks in advance!
apex list developer-console developer
apex list developer-console developer
New contributor
New contributor
edited 3 hours ago
New contributor
asked 3 hours ago
Max Goldfarb
83
83
New contributor
New contributor
2
What was your exec anon code? Could you edit the code in to your question?
– sfdcfox
3 hours ago
@sfdcfox updated the post, but here is the code I ran... ProjectStatus.Test();
– Max Goldfarb
3 hours ago
add a comment |
2
What was your exec anon code? Could you edit the code in to your question?
– sfdcfox
3 hours ago
@sfdcfox updated the post, but here is the code I ran... ProjectStatus.Test();
– Max Goldfarb
3 hours ago
2
2
What was your exec anon code? Could you edit the code in to your question?
– sfdcfox
3 hours ago
What was your exec anon code? Could you edit the code in to your question?
– sfdcfox
3 hours ago
@sfdcfox updated the post, but here is the code I ran... ProjectStatus.Test();
– Max Goldfarb
3 hours ago
@sfdcfox updated the post, but here is the code I ran... ProjectStatus.Test();
– Max Goldfarb
3 hours ago
add a comment |
2 Answers
2
active
oldest
votes
You're missing the parameter. Try :
public class ProjectStatus{
public static void Test() { // Notice I took out the bit between the ()
List<String> myArray = new List<String>(); // and added the variable as a local variable
// Removed the "list<>" from below code
for (pse__Proj__c p : [SELECT Id FROM pse__Proj__c WHERE Project_Status_Requirement__c = True LIMIT 1000]) {
myArray.add(String.valueOf(p));
}
System.debug(myArray);
}
}
If you wanted to try to use your method as is you would need to call it like so:
List<String> results = new List<String>();
ProjectStatus.Test(results);
Here's some documentation about method prototypes that might help you understand. Note, this is not a Salesforce specific issue, it can happen in all programming languages.
This article goes over scope to help understand what I mean by a local variable.
Copy-Pasta
public class ProjectStatus{
public static void Test() { // Notice I took out the bit between the ()
List<String> myArray = new List<String>(); // and added the variable as a local variable
for (Account a : [
SELECT Id
FROM Account
LIMIT 1000
]) {
myArray.add(String.valueOf(a));
}
System.debug(myArray);
}
}
Anon:
ProjectStatus.Test();
Your modification wouldn't work as is, missing variable definition.
– sfdcfox
3 hours ago
Fixed, thanks @sfdcfox
– gNerb
3 hours ago
@gNerb Sorry to bother you, I plan on thoroughly reading through the documentation you have sent, but I also tried changing my code as well as running it as it was with a parameter like you had commented but I am still receiving the following error... "Method does not exist or incorrect signature"
– Max Goldfarb
3 hours ago
I updated my code with copy pasta, please give that a try.
– gNerb
3 hours ago
1
@gNerb sounds good, i will keep digging into this issue and try to identify the root cause. I greatly appreciate the help and hope one day I am able to repay the favor! Glad I was able to resolve the original question and your insight added a ton of clarification into that issue, I should really spend more time reading documentation before jumping right into programming with a new language
– Max Goldfarb
2 hours ago
|
show 3 more comments
This error is telling you that you forgot some parameters (in this case, a string list object). You'd call your code like this:
String values = new String[0];
ProjectStatus.Test(values);
Note that your code is directly modifying the values in the parameter, which you can see by using debug:
String values = new String[0];
ProjectStatus.Test(values);
System.debug(values);
Sorry to bother you, I tried running with the parameter like you had commented but I am still receiving the following error... "Method does not exist or incorrect signature: void Test() from the type ProjectStatus"
– Max Goldfarb
3 hours ago
@MaxGoldfarb You still apparently missed the parameter; if you had provided a parameter, the error would have looked different.
– sfdcfox
2 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
});
}
});
Max Goldfarb is a new contributor. Be nice, and check out our Code of Conduct.
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%2f245240%2fcreate-list-of-strings-from-another-list-of-object-records%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You're missing the parameter. Try :
public class ProjectStatus{
public static void Test() { // Notice I took out the bit between the ()
List<String> myArray = new List<String>(); // and added the variable as a local variable
// Removed the "list<>" from below code
for (pse__Proj__c p : [SELECT Id FROM pse__Proj__c WHERE Project_Status_Requirement__c = True LIMIT 1000]) {
myArray.add(String.valueOf(p));
}
System.debug(myArray);
}
}
If you wanted to try to use your method as is you would need to call it like so:
List<String> results = new List<String>();
ProjectStatus.Test(results);
Here's some documentation about method prototypes that might help you understand. Note, this is not a Salesforce specific issue, it can happen in all programming languages.
This article goes over scope to help understand what I mean by a local variable.
Copy-Pasta
public class ProjectStatus{
public static void Test() { // Notice I took out the bit between the ()
List<String> myArray = new List<String>(); // and added the variable as a local variable
for (Account a : [
SELECT Id
FROM Account
LIMIT 1000
]) {
myArray.add(String.valueOf(a));
}
System.debug(myArray);
}
}
Anon:
ProjectStatus.Test();
Your modification wouldn't work as is, missing variable definition.
– sfdcfox
3 hours ago
Fixed, thanks @sfdcfox
– gNerb
3 hours ago
@gNerb Sorry to bother you, I plan on thoroughly reading through the documentation you have sent, but I also tried changing my code as well as running it as it was with a parameter like you had commented but I am still receiving the following error... "Method does not exist or incorrect signature"
– Max Goldfarb
3 hours ago
I updated my code with copy pasta, please give that a try.
– gNerb
3 hours ago
1
@gNerb sounds good, i will keep digging into this issue and try to identify the root cause. I greatly appreciate the help and hope one day I am able to repay the favor! Glad I was able to resolve the original question and your insight added a ton of clarification into that issue, I should really spend more time reading documentation before jumping right into programming with a new language
– Max Goldfarb
2 hours ago
|
show 3 more comments
You're missing the parameter. Try :
public class ProjectStatus{
public static void Test() { // Notice I took out the bit between the ()
List<String> myArray = new List<String>(); // and added the variable as a local variable
// Removed the "list<>" from below code
for (pse__Proj__c p : [SELECT Id FROM pse__Proj__c WHERE Project_Status_Requirement__c = True LIMIT 1000]) {
myArray.add(String.valueOf(p));
}
System.debug(myArray);
}
}
If you wanted to try to use your method as is you would need to call it like so:
List<String> results = new List<String>();
ProjectStatus.Test(results);
Here's some documentation about method prototypes that might help you understand. Note, this is not a Salesforce specific issue, it can happen in all programming languages.
This article goes over scope to help understand what I mean by a local variable.
Copy-Pasta
public class ProjectStatus{
public static void Test() { // Notice I took out the bit between the ()
List<String> myArray = new List<String>(); // and added the variable as a local variable
for (Account a : [
SELECT Id
FROM Account
LIMIT 1000
]) {
myArray.add(String.valueOf(a));
}
System.debug(myArray);
}
}
Anon:
ProjectStatus.Test();
Your modification wouldn't work as is, missing variable definition.
– sfdcfox
3 hours ago
Fixed, thanks @sfdcfox
– gNerb
3 hours ago
@gNerb Sorry to bother you, I plan on thoroughly reading through the documentation you have sent, but I also tried changing my code as well as running it as it was with a parameter like you had commented but I am still receiving the following error... "Method does not exist or incorrect signature"
– Max Goldfarb
3 hours ago
I updated my code with copy pasta, please give that a try.
– gNerb
3 hours ago
1
@gNerb sounds good, i will keep digging into this issue and try to identify the root cause. I greatly appreciate the help and hope one day I am able to repay the favor! Glad I was able to resolve the original question and your insight added a ton of clarification into that issue, I should really spend more time reading documentation before jumping right into programming with a new language
– Max Goldfarb
2 hours ago
|
show 3 more comments
You're missing the parameter. Try :
public class ProjectStatus{
public static void Test() { // Notice I took out the bit between the ()
List<String> myArray = new List<String>(); // and added the variable as a local variable
// Removed the "list<>" from below code
for (pse__Proj__c p : [SELECT Id FROM pse__Proj__c WHERE Project_Status_Requirement__c = True LIMIT 1000]) {
myArray.add(String.valueOf(p));
}
System.debug(myArray);
}
}
If you wanted to try to use your method as is you would need to call it like so:
List<String> results = new List<String>();
ProjectStatus.Test(results);
Here's some documentation about method prototypes that might help you understand. Note, this is not a Salesforce specific issue, it can happen in all programming languages.
This article goes over scope to help understand what I mean by a local variable.
Copy-Pasta
public class ProjectStatus{
public static void Test() { // Notice I took out the bit between the ()
List<String> myArray = new List<String>(); // and added the variable as a local variable
for (Account a : [
SELECT Id
FROM Account
LIMIT 1000
]) {
myArray.add(String.valueOf(a));
}
System.debug(myArray);
}
}
Anon:
ProjectStatus.Test();
You're missing the parameter. Try :
public class ProjectStatus{
public static void Test() { // Notice I took out the bit between the ()
List<String> myArray = new List<String>(); // and added the variable as a local variable
// Removed the "list<>" from below code
for (pse__Proj__c p : [SELECT Id FROM pse__Proj__c WHERE Project_Status_Requirement__c = True LIMIT 1000]) {
myArray.add(String.valueOf(p));
}
System.debug(myArray);
}
}
If you wanted to try to use your method as is you would need to call it like so:
List<String> results = new List<String>();
ProjectStatus.Test(results);
Here's some documentation about method prototypes that might help you understand. Note, this is not a Salesforce specific issue, it can happen in all programming languages.
This article goes over scope to help understand what I mean by a local variable.
Copy-Pasta
public class ProjectStatus{
public static void Test() { // Notice I took out the bit between the ()
List<String> myArray = new List<String>(); // and added the variable as a local variable
for (Account a : [
SELECT Id
FROM Account
LIMIT 1000
]) {
myArray.add(String.valueOf(a));
}
System.debug(myArray);
}
}
Anon:
ProjectStatus.Test();
edited 3 hours ago
answered 3 hours ago
gNerb
5,726734
5,726734
Your modification wouldn't work as is, missing variable definition.
– sfdcfox
3 hours ago
Fixed, thanks @sfdcfox
– gNerb
3 hours ago
@gNerb Sorry to bother you, I plan on thoroughly reading through the documentation you have sent, but I also tried changing my code as well as running it as it was with a parameter like you had commented but I am still receiving the following error... "Method does not exist or incorrect signature"
– Max Goldfarb
3 hours ago
I updated my code with copy pasta, please give that a try.
– gNerb
3 hours ago
1
@gNerb sounds good, i will keep digging into this issue and try to identify the root cause. I greatly appreciate the help and hope one day I am able to repay the favor! Glad I was able to resolve the original question and your insight added a ton of clarification into that issue, I should really spend more time reading documentation before jumping right into programming with a new language
– Max Goldfarb
2 hours ago
|
show 3 more comments
Your modification wouldn't work as is, missing variable definition.
– sfdcfox
3 hours ago
Fixed, thanks @sfdcfox
– gNerb
3 hours ago
@gNerb Sorry to bother you, I plan on thoroughly reading through the documentation you have sent, but I also tried changing my code as well as running it as it was with a parameter like you had commented but I am still receiving the following error... "Method does not exist or incorrect signature"
– Max Goldfarb
3 hours ago
I updated my code with copy pasta, please give that a try.
– gNerb
3 hours ago
1
@gNerb sounds good, i will keep digging into this issue and try to identify the root cause. I greatly appreciate the help and hope one day I am able to repay the favor! Glad I was able to resolve the original question and your insight added a ton of clarification into that issue, I should really spend more time reading documentation before jumping right into programming with a new language
– Max Goldfarb
2 hours ago
Your modification wouldn't work as is, missing variable definition.
– sfdcfox
3 hours ago
Your modification wouldn't work as is, missing variable definition.
– sfdcfox
3 hours ago
Fixed, thanks @sfdcfox
– gNerb
3 hours ago
Fixed, thanks @sfdcfox
– gNerb
3 hours ago
@gNerb Sorry to bother you, I plan on thoroughly reading through the documentation you have sent, but I also tried changing my code as well as running it as it was with a parameter like you had commented but I am still receiving the following error... "Method does not exist or incorrect signature"
– Max Goldfarb
3 hours ago
@gNerb Sorry to bother you, I plan on thoroughly reading through the documentation you have sent, but I also tried changing my code as well as running it as it was with a parameter like you had commented but I am still receiving the following error... "Method does not exist or incorrect signature"
– Max Goldfarb
3 hours ago
I updated my code with copy pasta, please give that a try.
– gNerb
3 hours ago
I updated my code with copy pasta, please give that a try.
– gNerb
3 hours ago
1
1
@gNerb sounds good, i will keep digging into this issue and try to identify the root cause. I greatly appreciate the help and hope one day I am able to repay the favor! Glad I was able to resolve the original question and your insight added a ton of clarification into that issue, I should really spend more time reading documentation before jumping right into programming with a new language
– Max Goldfarb
2 hours ago
@gNerb sounds good, i will keep digging into this issue and try to identify the root cause. I greatly appreciate the help and hope one day I am able to repay the favor! Glad I was able to resolve the original question and your insight added a ton of clarification into that issue, I should really spend more time reading documentation before jumping right into programming with a new language
– Max Goldfarb
2 hours ago
|
show 3 more comments
This error is telling you that you forgot some parameters (in this case, a string list object). You'd call your code like this:
String values = new String[0];
ProjectStatus.Test(values);
Note that your code is directly modifying the values in the parameter, which you can see by using debug:
String values = new String[0];
ProjectStatus.Test(values);
System.debug(values);
Sorry to bother you, I tried running with the parameter like you had commented but I am still receiving the following error... "Method does not exist or incorrect signature: void Test() from the type ProjectStatus"
– Max Goldfarb
3 hours ago
@MaxGoldfarb You still apparently missed the parameter; if you had provided a parameter, the error would have looked different.
– sfdcfox
2 hours ago
add a comment |
This error is telling you that you forgot some parameters (in this case, a string list object). You'd call your code like this:
String values = new String[0];
ProjectStatus.Test(values);
Note that your code is directly modifying the values in the parameter, which you can see by using debug:
String values = new String[0];
ProjectStatus.Test(values);
System.debug(values);
Sorry to bother you, I tried running with the parameter like you had commented but I am still receiving the following error... "Method does not exist or incorrect signature: void Test() from the type ProjectStatus"
– Max Goldfarb
3 hours ago
@MaxGoldfarb You still apparently missed the parameter; if you had provided a parameter, the error would have looked different.
– sfdcfox
2 hours ago
add a comment |
This error is telling you that you forgot some parameters (in this case, a string list object). You'd call your code like this:
String values = new String[0];
ProjectStatus.Test(values);
Note that your code is directly modifying the values in the parameter, which you can see by using debug:
String values = new String[0];
ProjectStatus.Test(values);
System.debug(values);
This error is telling you that you forgot some parameters (in this case, a string list object). You'd call your code like this:
String values = new String[0];
ProjectStatus.Test(values);
Note that your code is directly modifying the values in the parameter, which you can see by using debug:
String values = new String[0];
ProjectStatus.Test(values);
System.debug(values);
answered 3 hours ago
sfdcfox
248k11189424
248k11189424
Sorry to bother you, I tried running with the parameter like you had commented but I am still receiving the following error... "Method does not exist or incorrect signature: void Test() from the type ProjectStatus"
– Max Goldfarb
3 hours ago
@MaxGoldfarb You still apparently missed the parameter; if you had provided a parameter, the error would have looked different.
– sfdcfox
2 hours ago
add a comment |
Sorry to bother you, I tried running with the parameter like you had commented but I am still receiving the following error... "Method does not exist or incorrect signature: void Test() from the type ProjectStatus"
– Max Goldfarb
3 hours ago
@MaxGoldfarb You still apparently missed the parameter; if you had provided a parameter, the error would have looked different.
– sfdcfox
2 hours ago
Sorry to bother you, I tried running with the parameter like you had commented but I am still receiving the following error... "Method does not exist or incorrect signature: void Test() from the type ProjectStatus"
– Max Goldfarb
3 hours ago
Sorry to bother you, I tried running with the parameter like you had commented but I am still receiving the following error... "Method does not exist or incorrect signature: void Test() from the type ProjectStatus"
– Max Goldfarb
3 hours ago
@MaxGoldfarb You still apparently missed the parameter; if you had provided a parameter, the error would have looked different.
– sfdcfox
2 hours ago
@MaxGoldfarb You still apparently missed the parameter; if you had provided a parameter, the error would have looked different.
– sfdcfox
2 hours ago
add a comment |
Max Goldfarb is a new contributor. Be nice, and check out our Code of Conduct.
Max Goldfarb is a new contributor. Be nice, and check out our Code of Conduct.
Max Goldfarb is a new contributor. Be nice, and check out our Code of Conduct.
Max Goldfarb is a new contributor. Be nice, and check out our Code of Conduct.
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2f245240%2fcreate-list-of-strings-from-another-list-of-object-records%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
2
What was your exec anon code? Could you edit the code in to your question?
– sfdcfox
3 hours ago
@sfdcfox updated the post, but here is the code I ran... ProjectStatus.Test();
– Max Goldfarb
3 hours ago