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
uptime_andrewuptime_andrew 

"Unknown Property" Error When Setting Public Variable

I'm attempting to set a value for the custom variable "recordOwner".  When I click the "changeOwner" button below, I get the error:

 

"Error: Unknown property 'myLeadConvert.recordOwner'"

 

Any ideas on where I've gone wrong (presumabley a get/set issue):

 

apex:page standardController="Lead" extensions="myLeadConvert" title="Lead">
    <apex:outputField value="{!lead.Company}" rendered="false" />
    <apex:outputField value="{!lead.OwnerId}" rendered="false" />
    <apex:outputField value="{!lead.IsConverted}" rendered="false" />
    <apex:form id="theForm">  
        <apex:pageBlock title="Convert Lead - {!lead.Name} - Confirm Ownership" mode="maindetail">
            <apex:pageMessages escape="false"  />

            <apex:pageBlockSection title="Set Owner" columns="2" collapsible="false" >
				<apex:pageBlockSectionItem >
	        	<apex:outputLabel value="Opportunity Owner" for="userList"/>
	                 <apex:selectList value="{!recordOwner}" id="userList" size="1" >
	                     <apex:selectOptions value="{!userList}" />
	                 </apex:selectList>
				</apex:pageBlockSectionItem>
				<apex:pageBlockSectionItem />
				<apex:commandButton action="{!changeOwner}" value="Change Owner" />
            </apex:pageBlockSection>

            <apex:commandButton action="{!cancel}" value="Cancel" />            
        </apex:pageBlock>     
    </apex:form>
</apex:page>

 

public with sharing class myLeadConvert {
    public Lead myLead;
	public genHelpers gh;
	public sfMailer um;

	// record owner
    public User recordOwner;

    public uptimeLeadConvert (ApexPages.StandardController stdController) {
    	this.gh		= new genHelpers();
    	this.um		= new sfMailer();
        this.myLead = (Lead)stdController.getRecord();
        if(this.myLead.IsConverted == true) {
        	viewConvLead();
        	return;
        } 
        this.myLead.Status = 'Qualified - Pending';
    }

		public PageReference changeOwner() { 
			return null;
		}

	

	// page Reference Methods
        public PageReference viewConvLead() {
        	PageReference pg = new PageReference(this.myLead.Id);
            if(this.myLead.IsConverted == true) { 
                this.myLead.addError( 'ERROR: The lead has already been converted, you cannot convert again' );
	            pg         = new PageReference('/apex/myConvLeadView?id=' + this.myLead.Id);
	            pg.setRedirect(true);
            }
            return pg;
        }



    // Record Owner Routines for created Account/Contact/Opp
		public List<SelectOption> getUserList() { 
			Profile p = this.gh.getProfile('up.time Sales User');
			List<User> uList = [select Id, Name from User where IsActive = true AND ProfileId  = :p.Id AND UserType = 'Standard' order by Name];
			List<SelectOption> selList = new List<SelectOption>();
			
			//if(this.getRecordOwner() <> null)
			//	selList.add(new SelectOption(String.valueOf(this.recordOwner.Id), this.getRecordOwner().Name));
			selList.add(new SelectOption('', '--None--'));
				
	        for(User u : uList) 
	            selList.add(new SelectOption(String.valueOf(u.Id), u.Name));
			return selList;
		}   
    
		public User getRecordOwner() {
	    	if(this.recordOwner == null)
	    		this.recordOwner = [select Id, Name from User where Id = :this.myLead.OwnerId];
			return this.recordOwner;
		}

	    public void setRecordOwner(User myRecordOwner) {
	        this.recordOwner = myRecordOwner;
	    }	




}

 


Best Answer chosen by Admin (Salesforce Developers) 
Chamil MadusankaChamil Madusanka

Use

public User recordOwner{get;set;}

 Instead of

 

public User recordOwner;

 If a reply to a post answers your question or resolves your problem, please mark it as the solution to the post so that others may benefit.

All Answers

Chamil MadusankaChamil Madusanka

Use

public User recordOwner{get;set;}

 Instead of

 

public User recordOwner;

 If a reply to a post answers your question or resolves your problem, please mark it as the solution to the post so that others may benefit.

This was selected as the best answer
uptime_andrewuptime_andrew

Thanks chamil.

 

I ended up using your suggestion, but changed it to :

 

public Id recordOwnerId{get;set;} 

 which seemed to work better with the select list options we'd built out.

 

Thanks for your help!