Getting AggregateResult variables from Execute Anonymous WindowRun a standard set controller extension from execute anonymousCan I return entire record set when using the Execute Anonymous Window in Dev Console?Execute anonymous - switch projectsSOQL: Execute Anonymous and Query Editor returning different resultsAutomatic re-naming of bind variable in Execute Anonymous debug log - why did/does this happen?How SOQL For Loop instead of SOQL may solve System.LimitException: Too many query rows: 50001?Execute a schedulable class from execute anonymous windowAggregateResult looping over empty query?'Expecting colon' error in SOQL query when not using a variableRunning Batch in Execute Anonymous but throwing error: method does not exist or incorrect signature void format string from the type anon
Upside-Down Pyramid Addition...REVERSED!
How do LIGO and VIRGO know that a gravitational wave has its origin in a neutron star or a black hole?
Can Infinity Stones be retrieved more than once?
Randomness of Python's random
Can hackers enable the camera after the user disabled it?
What does this colon mean? It is not labeling, it is not ternary operator
Building a list of products from the elements in another list
Why is "Vayechulu" said 3 times on Leil Shabbat?
Why isn't nylon as strong as kevlar?
What is the most remote airport from the center of the city it supposedly serves?
Can a nothic's Weird Insight action discover secrets about a player character that the character doesn't know about themselves?
Where can I go to avoid planes overhead?
Purpose of のは in this sentence?
Why does this rising edge detector using a capacitor and a resistor work?
I'm in your subnets, golfing your code
How do I tell my manager that his code review comment is wrong?
Why is this entry signal showing green?
String won't reverse using reverse_copy
How can I support myself financially as a 17 year old with a loan?
How to convert a MULTIPOLYGON field stored as text to geometry data type in postGIS so that it can be plotted in QGIS
Why Isn’t SQL More Refactorable?
How does this change to the opportunity attack rule impact combat?
Can my company stop me from working overtime?
Shantae Dance Matching
Getting AggregateResult variables from Execute Anonymous Window
Run a standard set controller extension from execute anonymousCan I return entire record set when using the Execute Anonymous Window in Dev Console?Execute anonymous - switch projectsSOQL: Execute Anonymous and Query Editor returning different resultsAutomatic re-naming of bind variable in Execute Anonymous debug log - why did/does this happen?How SOQL For Loop instead of SOQL may solve System.LimitException: Too many query rows: 50001?Execute a schedulable class from execute anonymous windowAggregateResult looping over empty query?'Expecting colon' error in SOQL query when not using a variableRunning Batch in Execute Anonymous but throwing error: method does not exist or incorrect signature void format string from the type anon
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I am trying to execute a block of code using the Execute Anonymous Window that is meant to delete some duplicated data, but I am getting this weird error about a variable not existing even though my debugging says otherwise.
Here is what I have:
List<AggregateResult> ars = [SELECT YTPQuiz__c quiz FROM YTPQuestion__c GROUP BY YTPQuiz__c HAVING Count(Id) > 1];
System.debug(ars);
for (AggregateResult ar : ars)
System.debug(ar.quiz);
In the for-loop you will see I simply print the quiz variable I assigned during the SOQL statement, but I get an error saying that this variable does not exist.
If I replace this debug line with System.debug(ar) the log print out a bunch of object like:
DEBUG|AggregateResult:quiz=a1XY0000000012
DEBUG|AggregateResult:quiz=a1XY0000000013
DEBUG|AggregateResult:quiz=a1XY0000000014
DEBUG|AggregateResult:quiz=a1XY0000000015
Yet, I can't access the quiz variable.
If I don't alias YTPQuiz__c as quiz then it will print out
DEBUG|AggregateResult:YTPQuiz__c=a1XY0000000012
DEBUG|AggregateResult:YTPQuiz__c=a1XY0000000013
DEBUG|AggregateResult:YTPQuiz__c=a1XY0000000014
DEBUG|AggregateResult:YTPQuiz__c=a1XY0000000015
Yet, I get the error that ar.YTPQuiz__c variable doesn't exist. I even tried ar.expr0 and it said that variable doesn't exist.
I've done this exact same method of accessing AggregateResults in APEX classes and it works perfectly fine, but not this Anonymous Execution Window... What could possibly be wrong?
soql execute-anonymous aggregateresult
add a comment |
I am trying to execute a block of code using the Execute Anonymous Window that is meant to delete some duplicated data, but I am getting this weird error about a variable not existing even though my debugging says otherwise.
Here is what I have:
List<AggregateResult> ars = [SELECT YTPQuiz__c quiz FROM YTPQuestion__c GROUP BY YTPQuiz__c HAVING Count(Id) > 1];
System.debug(ars);
for (AggregateResult ar : ars)
System.debug(ar.quiz);
In the for-loop you will see I simply print the quiz variable I assigned during the SOQL statement, but I get an error saying that this variable does not exist.
If I replace this debug line with System.debug(ar) the log print out a bunch of object like:
DEBUG|AggregateResult:quiz=a1XY0000000012
DEBUG|AggregateResult:quiz=a1XY0000000013
DEBUG|AggregateResult:quiz=a1XY0000000014
DEBUG|AggregateResult:quiz=a1XY0000000015
Yet, I can't access the quiz variable.
If I don't alias YTPQuiz__c as quiz then it will print out
DEBUG|AggregateResult:YTPQuiz__c=a1XY0000000012
DEBUG|AggregateResult:YTPQuiz__c=a1XY0000000013
DEBUG|AggregateResult:YTPQuiz__c=a1XY0000000014
DEBUG|AggregateResult:YTPQuiz__c=a1XY0000000015
Yet, I get the error that ar.YTPQuiz__c variable doesn't exist. I even tried ar.expr0 and it said that variable doesn't exist.
I've done this exact same method of accessing AggregateResults in APEX classes and it works perfectly fine, but not this Anonymous Execution Window... What could possibly be wrong?
soql execute-anonymous aggregateresult
As far as I know you will need to usear.get('quiz')to be able to get the data here. If you don't have aliases, then you usear.get('expr0')and so on depending on the order of the field.
– Jayant Das
Apr 23 at 23:20
add a comment |
I am trying to execute a block of code using the Execute Anonymous Window that is meant to delete some duplicated data, but I am getting this weird error about a variable not existing even though my debugging says otherwise.
Here is what I have:
List<AggregateResult> ars = [SELECT YTPQuiz__c quiz FROM YTPQuestion__c GROUP BY YTPQuiz__c HAVING Count(Id) > 1];
System.debug(ars);
for (AggregateResult ar : ars)
System.debug(ar.quiz);
In the for-loop you will see I simply print the quiz variable I assigned during the SOQL statement, but I get an error saying that this variable does not exist.
If I replace this debug line with System.debug(ar) the log print out a bunch of object like:
DEBUG|AggregateResult:quiz=a1XY0000000012
DEBUG|AggregateResult:quiz=a1XY0000000013
DEBUG|AggregateResult:quiz=a1XY0000000014
DEBUG|AggregateResult:quiz=a1XY0000000015
Yet, I can't access the quiz variable.
If I don't alias YTPQuiz__c as quiz then it will print out
DEBUG|AggregateResult:YTPQuiz__c=a1XY0000000012
DEBUG|AggregateResult:YTPQuiz__c=a1XY0000000013
DEBUG|AggregateResult:YTPQuiz__c=a1XY0000000014
DEBUG|AggregateResult:YTPQuiz__c=a1XY0000000015
Yet, I get the error that ar.YTPQuiz__c variable doesn't exist. I even tried ar.expr0 and it said that variable doesn't exist.
I've done this exact same method of accessing AggregateResults in APEX classes and it works perfectly fine, but not this Anonymous Execution Window... What could possibly be wrong?
soql execute-anonymous aggregateresult
I am trying to execute a block of code using the Execute Anonymous Window that is meant to delete some duplicated data, but I am getting this weird error about a variable not existing even though my debugging says otherwise.
Here is what I have:
List<AggregateResult> ars = [SELECT YTPQuiz__c quiz FROM YTPQuestion__c GROUP BY YTPQuiz__c HAVING Count(Id) > 1];
System.debug(ars);
for (AggregateResult ar : ars)
System.debug(ar.quiz);
In the for-loop you will see I simply print the quiz variable I assigned during the SOQL statement, but I get an error saying that this variable does not exist.
If I replace this debug line with System.debug(ar) the log print out a bunch of object like:
DEBUG|AggregateResult:quiz=a1XY0000000012
DEBUG|AggregateResult:quiz=a1XY0000000013
DEBUG|AggregateResult:quiz=a1XY0000000014
DEBUG|AggregateResult:quiz=a1XY0000000015
Yet, I can't access the quiz variable.
If I don't alias YTPQuiz__c as quiz then it will print out
DEBUG|AggregateResult:YTPQuiz__c=a1XY0000000012
DEBUG|AggregateResult:YTPQuiz__c=a1XY0000000013
DEBUG|AggregateResult:YTPQuiz__c=a1XY0000000014
DEBUG|AggregateResult:YTPQuiz__c=a1XY0000000015
Yet, I get the error that ar.YTPQuiz__c variable doesn't exist. I even tried ar.expr0 and it said that variable doesn't exist.
I've done this exact same method of accessing AggregateResults in APEX classes and it works perfectly fine, but not this Anonymous Execution Window... What could possibly be wrong?
soql execute-anonymous aggregateresult
soql execute-anonymous aggregateresult
asked Apr 23 at 22:59
BlondeSwanBlondeSwan
34310
34310
As far as I know you will need to usear.get('quiz')to be able to get the data here. If you don't have aliases, then you usear.get('expr0')and so on depending on the order of the field.
– Jayant Das
Apr 23 at 23:20
add a comment |
As far as I know you will need to usear.get('quiz')to be able to get the data here. If you don't have aliases, then you usear.get('expr0')and so on depending on the order of the field.
– Jayant Das
Apr 23 at 23:20
As far as I know you will need to use
ar.get('quiz') to be able to get the data here. If you don't have aliases, then you use ar.get('expr0') and so on depending on the order of the field.– Jayant Das
Apr 23 at 23:20
As far as I know you will need to use
ar.get('quiz') to be able to get the data here. If you don't have aliases, then you use ar.get('expr0') and so on depending on the order of the field.– Jayant Das
Apr 23 at 23:20
add a comment |
2 Answers
2
active
oldest
votes
You will need to utilize ar.get(alias-name) here based on the Working with SOQL Aggregate Functions documentation.
So in your case it will be:
ar.get('quiz');
If you didn't have any aliasing, then you would have to use expri depending on the appearance of the field in the query.
add a comment |
If you alias the field, you then call .get('alias'). In your case, you would do something like:
for (AggregateResult aggregate : [
SELECT YTPQuiz__c quiz FROM YTPQuestion__c
GROUP BY YTPQuiz__c HAVING Count(Id) > 1
])
Id quizId = (Id)aggregate.get('quiz');
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%2f258860%2fgetting-aggregateresult-variables-from-execute-anonymous-window%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 will need to utilize ar.get(alias-name) here based on the Working with SOQL Aggregate Functions documentation.
So in your case it will be:
ar.get('quiz');
If you didn't have any aliasing, then you would have to use expri depending on the appearance of the field in the query.
add a comment |
You will need to utilize ar.get(alias-name) here based on the Working with SOQL Aggregate Functions documentation.
So in your case it will be:
ar.get('quiz');
If you didn't have any aliasing, then you would have to use expri depending on the appearance of the field in the query.
add a comment |
You will need to utilize ar.get(alias-name) here based on the Working with SOQL Aggregate Functions documentation.
So in your case it will be:
ar.get('quiz');
If you didn't have any aliasing, then you would have to use expri depending on the appearance of the field in the query.
You will need to utilize ar.get(alias-name) here based on the Working with SOQL Aggregate Functions documentation.
So in your case it will be:
ar.get('quiz');
If you didn't have any aliasing, then you would have to use expri depending on the appearance of the field in the query.
answered Apr 23 at 23:22
Jayant DasJayant Das
19.6k21331
19.6k21331
add a comment |
add a comment |
If you alias the field, you then call .get('alias'). In your case, you would do something like:
for (AggregateResult aggregate : [
SELECT YTPQuiz__c quiz FROM YTPQuestion__c
GROUP BY YTPQuiz__c HAVING Count(Id) > 1
])
Id quizId = (Id)aggregate.get('quiz');
add a comment |
If you alias the field, you then call .get('alias'). In your case, you would do something like:
for (AggregateResult aggregate : [
SELECT YTPQuiz__c quiz FROM YTPQuestion__c
GROUP BY YTPQuiz__c HAVING Count(Id) > 1
])
Id quizId = (Id)aggregate.get('quiz');
add a comment |
If you alias the field, you then call .get('alias'). In your case, you would do something like:
for (AggregateResult aggregate : [
SELECT YTPQuiz__c quiz FROM YTPQuestion__c
GROUP BY YTPQuiz__c HAVING Count(Id) > 1
])
Id quizId = (Id)aggregate.get('quiz');
If you alias the field, you then call .get('alias'). In your case, you would do something like:
for (AggregateResult aggregate : [
SELECT YTPQuiz__c quiz FROM YTPQuestion__c
GROUP BY YTPQuiz__c HAVING Count(Id) > 1
])
Id quizId = (Id)aggregate.get('quiz');
answered Apr 23 at 23:20
Adrian Larson♦Adrian Larson
111k19122261
111k19122261
add a comment |
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%2f258860%2fgetting-aggregateresult-variables-from-execute-anonymous-window%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
As far as I know you will need to use
ar.get('quiz')to be able to get the data here. If you don't have aliases, then you usear.get('expr0')and so on depending on the order of the field.– Jayant Das
Apr 23 at 23:20