Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [execute-anonymous]

The Execute Anonymous Apex tool in the Developer Console runs the Apex code you enter using ExecuteAnonymous and generates a debug log with the results of the execution.

3
votes
2answers
46 views

Getting AggregateResult variables from Execute Anonymous Window

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 ...
0
votes
2answers
56 views

Running Batch in Execute Anonymous but throwing error: method does not exist or incorrect signature void format string from the type anon

I need to run a scheduled batch out of schedule. It has been working every day perfectly for months. I went to try to run it in Execute Anonymous but I get the error: Method does not exist or ...
0
votes
1answer
33 views

Updating 600 rows of opportunity gives error time limit exceeded [duplicate]

I have the following apex file to update about 600 opportunity records that have status1 as Active and status2 as Inactive. status2 is a formula, status1 is a text field. Running this via Execute ...
0
votes
0answers
17 views

One time Script in batches - Developer Console [duplicate]

I wrote a script to update a field value on several thousand records based on certain criteria. I will only be doing this one time, and that's the reason for not putting the logic in an Apex Class. ...
0
votes
1answer
23 views

Add value to list of valid States

I added a new State for the Country 'Canada' in Setup -> State and Country/Territory Picklists. The State is 'BC' and StateCode is 'BC2'. See the image below for how it looks: Now that 'BC' is a ...
1
vote
1answer
490 views

Execute anonymous unexpected token '<'

I receive this error: Line: 5, Column: 4 unexpected token: '<' When executing this code in the execute anonymous window in the developer console: Map<String, List<Custom_Object__c>>...
1
vote
1answer
42 views

Failure when inserting records via dataloader, however anonymous apex inserts fine

I'm getting the following error when running dataloader (inserting new quotelineitems), however an identifcal anonymous apex works fine - any thoughts? Error: The price book entry is in a different ...
1
vote
1answer
192 views

Execute anonymous Unexpected Token

I'm trying to insert a record into a custom object via Execute Anonymous and get Line 2, Column 19 Unexpected Token 'InvA' This is sample code from Trailhead and it uses the Account object as an ...
0
votes
1answer
67 views

Using tooling API in executeAnonymous

I am writing a script that automatically builds package.xml for ANT development. However there are some metadata that I can't fetch in executeAnonymous since it require tooling api. Is there a way to ...
0
votes
1answer
53 views

Anonymous window Too many SOQL queries: 101

I've tried to execute the following script: List<Task> taskList = [SELECT status, CalculatedWorkingHours__c FROM Task WHERE CalculatedWorkingHours__c = -1.0 AND status = 'Completed']; ...
0
votes
1answer
147 views

copy all files to a library using apex Salesforce [closed]

I am trying to pass several files through the anonymous window to a library using ContentWorkspaceDoc, someone can help me. this is my code: List<ContentDocument> dc = [Select id, Title From ...
0
votes
1answer
41 views

how to create opportunity in related list of contact from anonymous window

I want to create a chain record like contact is related list of account and opportunity is related list of that contact which is connect to account(same account). i am able to insert them ...
0
votes
2answers
148 views

DML Error After Rollback

Below is my code which I'm executing in developer console. Contact con = new Contact( LastName = 'JOHNSON', LeadSource = 'Web'); Savepoint sp = Database.setSavepoint(); insert con; Database.rollback(...
0
votes
2answers
30 views

Unable to query Accounts with Related activities

I am unable to query accounts with related task Criteria List<Account> acc= new List<Account>(); acc=[Select id,name from account where Id IN (Select id,WhatId,CreatedBy.Name,ActivityDate,...
0
votes
1answer
253 views

How to convert Bulk Leads by executing Apex Code in anonymous Window [duplicate]

Business requirement is to convert 1000 leads which are owned by a user, I heard that we can right a adhoc Apex code in anonymous Window and execute it to convert. Can any one help me in providing ...
0
votes
2answers
151 views

Anonymous Block Query for Related Column from a Custom Object

I am trying to display firstname from contact but am getting this: Line: 1, Column: 36 id, (select id , firstname from contact) from Company_Contact_Relation__c ^ ERROR at Row:1:Column:40 Didn't ...
3
votes
1answer
42 views

Anonymous Block Query for Related Column

I am trying to get the actual DeveloperName to display from the anonymous block code but all I can seem to get is the ID. Contact C = [Select id, FirstName, Recordtype.DeveloperName from contact ...
1
vote
1answer
34 views

Need to update historical Record for status changed date in Case

Below are my scenarios need to achieve in an anonymous script. I have created 5 fields (ClosedDate__c, NewStatusDate__c, EscalateDate__c, InProgressDate and OnHoldDate__c). In my instance, I have ...
3
votes
1answer
108 views

List in anonymous script returns rows but apex class returns empty?

I have a soql on a custom object this returns 2 rows in the Anonymous window and in the Query editor. If I use the same query in an apex class it returns empty. I is there something I am missing. ...
2
votes
1answer
35 views

Custom Object Relationship query behaves differently in Test from Execute Anonymous

Background I have a custom object Contact_Coverage__c. I have a custom field Contact_Coverage__c added to the Activity standard object, with the child relationship name Activities__r. In general, I ...
0
votes
2answers
69 views

System.LimitException

I run this code in Developer console, Execute anonymous. How can I resolve this Limit exception : Line: 1, Column: 1 System.LimitException: Too many query rows: 50001 I definitely have more ...
0
votes
1answer
465 views

Execute Anonymous error - Method does not exist or incorrect signature

I am trying to execute anonymous apex block. The method which is used here is also used in a trigger. Trigger is working fine. I am writing this apex code to update a new field based on the values of ...
0
votes
1answer
726 views

Apex Anonymous With Batch Apex Constructor Issue

I am sure there is a simple explanation but when I run in Anonymous Apex my Batchable class I get error: Constructor not defined: [BatchableEncryptedEmailBackfill].<Constructor>(). It is to my ...
-1
votes
2answers
506 views

Why cant I see my debug logs from anonymous window

I have this piece of code which I like to test from the anonymous window. I aded a static Id from the org. Why do my debugs return empty? here is my code in the anonymous window: public static ...
0
votes
2answers
440 views

Execute Anonymous and Custom Objects

To test updating a custom object field via a trigger, I'm executing an update in Execute Anonymous to test the code. My test works on standard objects (Contact), but it doesn't recognize my custom ...
1
vote
1answer
253 views

Syntax error when running class from execute anonymous

I am trying to run a class in execute anonymous window to test, but am encountering an odd error. Here is a simplified version of the class: public class AddEmailProduct1 { public static void ...
0
votes
2answers
278 views

Execute a schedulable class from execute anonymous window

I'm having trouble executing a schedulable class from the execute anonymous window. I used to used the following format: QA_Biemanal s=new QA_Biemanal(); s.execute(null); For some reason it's not ...
3
votes
2answers
1k views

Creating a class in Anonymous Window

If I create a class in Anonymous window and use it's object in a method. Will it force to run all the test classes in production? I need to schedule a class, so I have to implement schedulable. ...
0
votes
0answers
48 views

Error when executing schedulable class “no viable alternative at character ' ' ”

I'm having an issue executing a schedulable class. My Schedulable Class: global class Recordatorio_Cobro implements Schedulable { global void execute(SchedulableContext SC) { ...
1
vote
1answer
2k views

System.LimitException: Maximum stack depth reached: 1001 Error [duplicate]

I'm not sure Why I'm getting this Error Message without any indication of what line is the error from. I remove the parameter from the Constructor because I'm planning on shifting this code to the ...
6
votes
1answer
5k views

Developer Console, Execute Anonymous - HTTP CODE[414]

When I'm trying to use Execute Anonymous with a large chunk of code, the following error pops up: Line: undefined, Column: undefined Response to EXEC was : . HTTP CODE[414] (414 stands for ...
4
votes
2answers
2k views

How to run an asynchronous job in developer console?

I want to find a quick way to be able to run ad-hoc pieces of Apex code asynchronously in developer console so I have higher limits. I want to be able to write and update this code quickly (no sandbox ...
0
votes
2answers
376 views

how to get count of record using anonymous code

I am trying to get the count of records where field value!=null using anonymous code. list<string> lstfields=new list<string>(); lstfields.add(Account_Manager__c); lstfields.add(...
-1
votes
2answers
2k views

Calling apex class from execute anonymous

I have the following class: public class ABC{ public ABC(Apexpages.standardcontroller s){ string param1 = ApexPages.currentPage().getParameters().get('v1'); //blah blah blah } ...
1
vote
1answer
2k views

Batch Apex Anonymous execution

Why am I not able to execute this batch class? I copied it from trail head tutorial, Batch Class global class UpdateContactAddresses implements Database.Batchable<sObject>, Database....
0
votes
1answer
1k views

User input in apex class using developer console

as am new to Apex programming. Am learning the apex using developer console and want to take the user input using the execution window.I want to take user input for array with 25 elements. How can we ...
2
votes
2answers
1k views

scheduling a batch class to run every 15 min in managed package

I am trying to schedule a batch class to run every 2 min. What I tried so far is : global class schlerclass implements Schedulable{ global void execute(SchedulableContext sc) { // Re-...
1
vote
2answers
416 views

Code without sharing information

If with sharing or without sharing is not specified in the following, will only the controller run with sharing? I think only apex controller and anonymous block will respect the OWD and sharing ...
1
vote
2answers
1k views

how to execute anonymous block of apex code in sublimeText 3 with mavensmate [closed]

I'm actually using sublimeText3 with mavensmate to code in apex. But i don't know how to execute anonymous block of code. Does anyone try it out?
1
vote
1answer
748 views

Messaging.SingleEmailMessage method compiles anonymously but not in a class

Here's the issue: I'm trying to use the method Messaging.SingleEmailMessage.setEntityAttachments(List<Id>) in a class, but it won't compile. However, when I run the same code in anonymous apex, ...
1
vote
1answer
20 views

A recently deployed field shows up on objects, but is not available when executing in “Execute Anonymous Window”

I get this pretty standard error: Line: 1, Column: 25 No such column 'card_version__c' on entity 'Account'. If you are attempting to use a custom field, be sure to append the '__c' after the custom ...
3
votes
2answers
541 views

Execute anonymous(Eclipse), Developer console and Query editor

Does the Query Editor or Execute Anonymous (either via the Eclipse IDE or the Developer Console) run in System Mode or User Mode?
2
votes
2answers
527 views

Difference when invoking Apex in execute anonymous vs. unit tests?

I'm looking at the study guide for the Platform Developer 1 certification. Under the Testing section one of the headings is: Describe the difference between invoking Apex in execute anonymous vs. ...
-1
votes
1answer
79 views

Generating thousands of records in salesforce using Apex

can I run an apex class through execute anonymous to generate thousands of records of an object in salesforce? List<Account> accList = new List<Account>(); for(integer i=0;i<200000;i++)...
1
vote
1answer
85 views

Update Owner of Account with Sales Rep associated with Account

I am new to APEX Code and I am having some trouble accomplishing a task assigned to me I am trying to execute anonymous code that will get all accounts where the owner is a specific name. Then update ...
0
votes
1answer
45 views

Need help to update cases in bulk

I am trying to update cases in bulk referring to a question here i am trying to run a script via execute anonymous to update old cases in bulk, but all the cases are being updated with the response ...
6
votes
2answers
935 views

Does execute anonymous from Developer Console not enforce heap size limit?

I have been investigating a potential heap size problem in our production code, and I wanted to recreate some simple elements through the developer console. To cause a heap size exception, I would ...
5
votes
1answer
648 views

Bug in Dev Console/Execute Anonymous?

I am trying to do some research, and coming across a stumbling block. Execute Anonymous seems to sometimes hit a statement that breaks all further debugs. system.debug('Statements do appear'); // ...
1
vote
1answer
492 views

How to execute a code inside an executeAnonymous block of toolingAPI in salesforce?

Below is a piece of code I am trying to run. global class TriggerClass { @future (callout=true) public static void ifMethod(String sessionId, String ifcondition) { ToolingAPI....
1
vote
1answer
635 views

Salesforce Trailhead Projects - Creating an Apex Class (Emails)

I'm working through the trailhead projects, and am currently on the one where I need to create a class to send an email (https://developer.salesforce.com/trailhead/project/...