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
AlexhtAlexht 

Error with account name with person accounts enabled

<apex:page standardController="Quote__c"  tabStyle="Opportunity" >
  <apex:form > 
  <apex:pageBlock title="Quote Edit" tabStyle="Opportunity">

      <apex:pageBlockSection title="test" showHeader="false">
      <apex:pageBlockSectionItem>
                  <apex:outputLabel>Account Name</apex:outputLabel>
                  <apex:outputField value="{!Quote__c.Opportunity__r.Account}"/>
      </apex:pageBlockSectionItem>
      </apex:pageBlockSection>
      
   </apex:pageBlock>

  </apex:form>
</apex:page>

 

This visualforce page is overriding a New button. My org uses person account. Quote__c is the child of a master-child relationship with opportunity. When I click the new button from opportunity, I get this error message.

 

 

Validation Errors While Saving Record(s)
There were custom validation error(s) encountered while saving the affected record(s). The first validation error encountered was "Account ID: value not of required type: core.apexpages.el.adapters.metadata.SObjectMetadataELAdapter@b473136". 

Click here to return to the previous page.
sekharasekhara

Hi Alexht,

 

U want to display account name in Override Vf Page?

 

If so u can use Query String Parameters . For passing Account name in ur page.

 

 

Let me know in case of any issues.

AlexHt1AlexHt1

Thank you,

 

I went with this code to extract the id from the url. Now I can override the standand new object and still get the opportunity object.

 

String URL = ApexPages.currentPage().getUrl();
		String [] params = URL.Split('&');
		
		this.id='';
		
		for (String s : params)
		{
			String [] get_element = s.Split('=');
			if (get_element[0].substring(get_element[0].length()-2, get_element[0].length()) == 'id')
			{
				this.id = get_element[1];
			}
		}

        if(this.id == null || this.id == '')
        {
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.FATAL,'ERROR_ID_MISSING'));
        }