• Pratyush Kumar 44
  • 0 Points
  • Member since 2015

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
  • 6
Hello Friends,

I was going through the trailhead and happened to execute the below code:

public static void updateOlderAccounts() {
    // Get the 5 oldest accounts
    Account[] oldAccounts = [SELECT Id, Description FROM Account ORDER BY CreatedDate ASC LIMIT 5];
    // loop through them and update the Description field
    for (Account acct : oldAccounts) {
        acct.Description = 'Heritage Account';
   // save the change you made
   update oldAccounts;

But its showing error on line 1 - unexpected token: 'void'

Can anyone please help?

Thanks in advance!
I am working on the Trailhead challenge asking me to create a formula field calculating the volume of a cylinder.  I am 99% sure my formula is correct but the error message I am getting is asking me to include a "required field" that is not mentioned in the challenge.  Here is the prompt:
Your company sells cylindrical hyperbaric chambers. You need a formula field that calculates the volume of a cylinder for you, rounded to the nearest whole number, given its radius and height. Use the existing mathematical formula for the volume of a cylinder, V = πr2h, where r is the radius of the cylinder, h is the height, and π is the constant Pi. Note: Although this formula field might best be created on a custom object, for simplicity, we’ll create this formula on the Opportunity object.Create 2 custom fields of type Number on the Opportunity object: ‘radius’ with a resulting API name of ‘radius__c’ and ‘height’ with a resulting API name of ‘height__c’.
The formula should be named ‘Cylinder Volume’, with the resulting API name ‘Cylinder_Volume__c‘ and should be created on the Opportunity object.
The formula should reference the custom fields ‘radius__c‘ and ‘height__c‘.
The formula should use 3.14159 as an approximation of Pi.
Here is my formula: 3.14159 *  (radius__c ^2) *  height__c

Here is my error message:
User-added image

Any help would be appreciated!
I do not understand how to fix this. This message came up while I was trying to do a challenge in Trailhead "The 'Account Manager' contact role for 'Washington Industries' could not be found or it is not set to the current user."