Skip to main content The Trailblazer Community will be unavailable from 2/1/2025 to 2/2/2025. Please plan your activities accordingly.
I'm building a sort of audit vf page for our products and was wondering if there is a way to make this circle(shown), then when a users clicks this circle once and it turns green, click twice and it turns yellow, click 3 times and it turns red.  

User-added image
11 answers
  1. Jan 6, 2023, 4:27 PM
    @TobyKutler

    It makes me change the class to this

    public without sharing class ChangeColorController {

    public ChangeColorController(ApexPages.StandardController controller) {

    }

    integer clickCount = 0;

    string imageUrl;

    List<StaticResource> green = [SELECT Id, Body FROM StaticResource WHERE Name = 'RatingGreen'];

    List<StaticResource> yellow = [SELECT Id, Body FROM StaticResource WHERE Name = 'RatingYellow'];

    List<StaticResource> red = [SELECT Id, Body FROM StaticResource WHERE Name = 'RatingRed'];

    List<StaticResource> grey = [SELECT Id, Body FROM StaticResource WHERE Name = 'RatingGrey'];

    List<StaticResource> blank = [SELECT Id, Body FROM StaticResource WHERE Name = 'RatingBlank'];

    public ChangeColorController(){

    imageUrl = blank[0].Body.toString();

    }

    public void RatingChange()

    {

    clickCount++;

    if(clickCount == 1){

    imageUrl = green[0].Id;

    }

    else if(clickCount == 2){

    imageUrl = yellow[0].Id;

    }

    else if(clickCount == 3){

    imageUrl = red[0].Id;

    }

    else if(clickCount == 4){

    imageUrl = grey[0].Id;

    }

    else if(clickCount == 5){

    imageUrl = blank[0].Id;

    }

    }

    }

    and I updated the apex page to this <apex:commandButton image="{!URLFOR(imageUrl)}" onClick="RatingChange()" /></apex:column>

    but when saving the apext page its saying "Error: Unknown property 'Audit_Report__cStandardController.imageUrl'"

     
Loading
0/9000