function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Bill ButtonBill Button 

arguments must be compatible types schema.SObjectField, Integer

Hi,
 
Not sure why I am getting this error or how to get round it, the field has been defined as a Number(1,0) but I get an error when I compare this to 0 or 1. The filed has 3 possible values 0,1,2 currently.
 
 
 public String Edgecam_BGColor() {
  string BGColor = '';
  
  // ss_edgecam__c is defined as Number(1, 0)
  // but on the if's I get an error when saving
  // Comparison arguments must be compatible types
  // schema.SObjectField, Integer
  
  if (account.ss_edgecam__C == 0) {
   BGColor = '';
  } else if (account.ss_edgecam__C == 1) {
   BGColor = '#C0FFC0';
  } else {
   BGColor = '#FFC0C0';
  }
  return BGColor;
 
mikefmikef
Bill
Even if you create a number as (1,0) in the UI it is stored as a Double 0.0.
Either add 0.0 to your compare in your if statements, or use Integer.valueOf(account.ss_edgecam__C) == 0.
SuperfellSuperfell
Whare are you setting account? there doesn't appear to be any account varaible in scope, so your actually getting the metadata for account/field hence the error, account.ss_edgecam__c is returning a type of SObjectField, not the value of that field in a particular account row.
Bill ButtonBill Button
Hi,
 
I tried this both ways and when using the 0.0 1 get an error "arguments must be compatible types" when I use the Integer.valueOf I get an error "Method does not exist or incorrecty signature."
 
Regards
Bill
Bill ButtonBill Button
Hi,
 
Thanks that got me on the right track, and the error has gone.
 
Thanks for all the help.
 
Bill
 
 
public class SupportStatusController {
 private final Account acct;
    public SupportStatusController(ApexPages.StandardController stdController) {
  this.acct = (Account)stdController.getRecord();
    }
 public String Edgecam_BGColor() {
  string BGColor = '';
  
  // ss_edgecam__c is defined as Number(1, 0)
  // but on the if's I get an error when saving
  // Comparison arguments must be compatible types
  // schema.SObjectField, Integer
  
 if (this.acct.ss_edgecam__C == 0) {
   BGColor = '';
  } else if (this.acct.ss_edgecam__C == 1) {
   BGColor = '#C0FFC0';
  } else {
   BGColor = '#FFC0C0';
  }
 return BGColor;
 }
}