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
ReddyReddy 

Unknown method 'AccountInformation.save()'----- vf page;

Unknown method 'AccountInformation.save()'----- vf page;

<apex:page Controller="AccountInformation"  tabStyle="Account" >
    <apex:form>
        <apex:pageblock title="Account Details" mode="edit">
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="save"/>
                <apex:commandButton action="{!new}" value="new" />
                <apex:commandButton action="{!delete}" value="delete"  />    
            </apex:pageBlockButtons>
            <apex:pageBlockSection title="My Data section" columns="2">
                Name:<apex:inputField value="{!account.name}"/>
                AccountNumber:<apex:inputField value="{!account.account number}"/>
                Industry:<apex:inputField value="{!account.industry}" />
            </apex:pageBlockSection>
        </apex:pageblock>
    </apex:form>
</apex:page>
==============================

unexpected token: 'list'  --- ( error message)

public class AccountInformation {
    public string name{set;get;}
    public string industry{set;get;}
    public integer AccountNumber{set;get;}
    public accountInformation data
    {
        list<account> acc = new list<Account>();
            Account a= new Account();    
            a.name='narendar';
            a.industry='energy';
            a.Account Number=1412001;
            insert a;
        system.debug('list of value:' +acc);
    }
Best Answer chosen by Reddy
Amit Chaudhary 8Amit Chaudhary 8
Same code is working fine in my org.  please Save Apex class first then update VF page.

User-added image

Page
User-added image

User-added image

All Answers

Amit Chaudhary 8Amit Chaudhary 8
You are using controller in VF page not Statandard Controller that is why SAVE method is not available for you
1) https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/apex_ApexPages_StandardController_methods.htm

Please update your code like below
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/apex_pages_standardcontroller.htm
 
public class myControllerExtension {

    private final Account acct;
    
    // The extension constructor initializes the private member
    // variable acct by using the getRecord method from the standard
    // controller.
    public myControllerExtension(ApexPages.StandardController stdController) {
        this.acct = (Account)stdController.getRecord();
    }

    public String getGreeting() {
        return 'Hello ' + acct.name + ' (' + acct.id + ')';
    }
}
<apex:page standardController="Account" extensions="myControllerExtension">
    {!greeting} <p/>
    <apex:form>
        <apex:inputField value="{!account.name}"/> <p/>
        <apex:commandButton value="Save" action="{!save}"/>
    </apex:form>
</apex:page>

Let us know if this will help you
 
ReddyReddy
hi Amit sir...........,
 lets tell me Error message...........
Amit Chaudhary 8Amit Chaudhary 8
That error is coming because you did not added any Save method in your apex class
ReddyReddy
Sorry sir jest tell me my Over code and one write it total code
 
Amit Chaudhary 8Amit Chaudhary 8
Update your code like below
<apex:page Controller="AccountInformation"  tabStyle="Account" >
    <apex:form >
        <apex:pageblock title="Account Details" mode="edit">
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="save"/>
                
                <!--
                <apex:commandButton action="{!new}" value="new" />
                <apex:commandButton action="{!delete}" value="delete"  />    
                -->
                
            </apex:pageBlockButtons>
            <apex:pageBlockSection title="My Data section" columns="2">
                   <apex:inputField value="{!acc.name}"/>
                   <apex:inputField value="{!acc.accountNumber}"/>
                  <apex:inputField value="{!acc.industry}" />
            </apex:pageBlockSection>
        </apex:pageblock>
    </apex:form>
</apex:page>
Class like below
public class AccountInformation {
    public string name{set;get;}
    public string industry{set;get;}
    public string AccountNumber{set;get;}
    public Account acc {get;set;}

    public AccountInformation()
    {
        acc = new Account();
    }
    
    public PageReference Save()
    {
        insert acc ;
        return new PageReference('/'+acc.id);
    }
}


Let us know if this will help you
 
ReddyReddy
HI @Amit Chaudhary  same error will be accrued. not working your code so sory
 
ReddyReddy
Unknown method 'AccountInformation.save()'
unexpected token: 'public'
Amit Chaudhary 8Amit Chaudhary 8
Same code is working fine in my org.  please Save Apex class first then update VF page.

User-added image

Page
User-added image

User-added image
This was selected as the best answer
ReddyReddy
User-added image this is symble how to use in my account name field.(Message:- enter your Account name ) User-added image