---
schema_version: "1"
id: 922f465dcfb2b096dcd297d83fedc4be656331cafc7193bc022a66e6f3527616
title: Apex Tasks
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/salesforcedx/sfvscode/guides/programming-languages/apex/apex-tasks.md
canonical_url: https://developer.salesforce.com/docs/platform/sfvscode-extensions/guide/apex-tasks.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: b18d1f7ea923a669635ee77ecf86320f63d3ac6cebe21ee57277ef2d0c767269
products:
  - Salesforce Extensions for Visual Studio Code
  - salesforcedx
---
# Apex Tasks

The [Apex Recipes](https://github.com/trailheadapps/apex-recipes) Github repository contains sample Apex tasks that you can complete in Agentforce Vibes IDE or VS Code using the Salesforce Extensions.

## Use Anonymous Apex to Mass Update Account Ratings

In addition to the tasks in the Apex Recipes repository, you can complete this sample task to try out running Anonymous Apex in VS Code.

Say you have accounts with `Rating` set to `Cold` because of unfavorable business conditions. You now want to make mass updates to these accounts and change their rating to `Warm`. You want to limit this update to mid-sized accounts with more than a certain amount of revenue.

This Anonymous Apex code updates ratings of accounts that have an annual revenue greater than `$10,000,000` and have more than `1000` employees:

1.  In the `scripts/apex` folder, create an Anonymous Apex file using the `.apex` file extension.
    Paste this code into the file:

          ```
          List<Account> acctList =[SELECT Name, Rating FROM Account
            WHERE AnnualRevenue > 500000 AND NumberOfEmployees > 100];
          for (Account acc: acctList){
              if (acc.Rating == 'Cold') {
                  acc.Rating = 'Warm';
                  update acc;
              }
                  System.debug(acc.Name + acc.Rating);
          }
          ```

2.  Click **Execute Anonymous Apex** to execute your code.

The `DEBUG CONSOLE` lists accounts and their updated ratings.

## See Also

- [_Salesforce Help_: Introducing Apex Recipes](https://developer.salesforce.com/blogs/2020/10/introducing-apex-recipes)
- [_Trailhead_: Quick Start: Explore the Apex Recipes Sample App](https://trailhead.salesforce.com/content/learn/projects/quick-start-explore-the-apex-recipes-sample-app)
