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
Chris Sanchez 5Chris Sanchez 5 

pass account.name to controller

Hello - In the below image Account.Name populates to my vf page just fine when the id is entered into the URL.  The controller from the other image below uses the fields in the vf page to do an insert to a custom object called customerFeedback.  The input text fields insert just fine but how can I rework my controller to pass the value of Account.Name to objcfb.Account__c.  The account name is a required field for customerFeedback records.  Please help.
User-added image
Ryan GreeneRyan Greene
Try:
objcfb.Account__c = [SELECT Name FROM Account WHERE id = :ApexPages.currentPage().getParameters().get('id')]
Edit if needed. Are the "deets" and "nam" getting populated?
Chakradhari GadigeChakradhari Gadige
Chris,

In cunstroctor use:
Account a = [SELECT Id, Name FROM Account WHERE Id = :ApexPages.currentPage().getParameters().get('id')];
        acct = a.Name;

In VF page:

<apex:inputText value="{!acct}" />  // By Replacing <apex:inputText value="{!Account.Name}" />
Chris Sanchez 5Chris Sanchez 5
Ryan – Yes, deets and nam are populating. I receive the following error when I added your code. Any ideas? Thanks for your help. [cid:image001.png@01D270D6.A7F6B040] Thanks, Chris
Chris Sanchez 5Chris Sanchez 5
Chakradhari, I entered everyting you mentioned but now when I enter ?id=xxxxxxxx to the url the account name no longer populates to the page. I would like the account to populate when clicking on a link that has the id. Then I would like to do an insert to the customer feedback object and set the field a.Name to the account Id in the URL and the same account that populates to the vf page when its first rendered. Any ideas. Thank you
Chris Sanchez 5Chris Sanchez 5
Yours worked well enough to get me to where I needed. I had to change acct=a.Name to acct=a.Id and add objcfb.Account__c=acct. Thank you so much for your help. Thanks, Chris
Chakradhari GadigeChakradhari Gadige
Hi Chris, If your your issue is resolved, pls mark it as Best Answer !! *Regards* *Chakri*
Chris Sanchez 5Chris Sanchez 5
I don’t see where to do that, lol. Yes I’m pretty new to all this. Thanks, Chris