You need to sign in to do that
Don't have an account?
I am AB
Record not inserted. Please help
Hi Expert,
I am very new the salesforce.
I want to insert a records in my custom object Invoice__c, But nothing is inserted with this code.
Thanks in advance
Sherry !
I am very new the salesforce.
I want to insert a records in my custom object Invoice__c, But nothing is inserted with this code.
VF page code: <apex:page standardController="Invoice__c" extensions="particular" docType="Html-5.0" sidebar="false" tabStyle="invoice__tab"> <apex:form > <apex:pageBlock title="Invoice Details" > <apex:pageBlockSection title="Account Details" columns="1"> <apex:inputfield Value="{!Invoice__c.Account_Name__c}"/> </apex:pageBlockSection> <apex:pageBlockSection title="Invoice Details" columns="2"> <apex:inputField Value="{!Invoice__c.Invoice_Date__c}"/> <apex:inputField value="{!Invoice__c.Description__c}"/> <apex:inputField value="{!Invoice__c.Net_Total__c}"/> </apex:pageBlockSection> <apex:pageBlockButtons > <apex:commandButton Value="Save" action="{!save}"/> <apex:commandButton Value="Cancel" action="{!cancel}"/> </apex:pageBlockButtons> </apex:pageBlock> </apex:form> </apex:page> Controller Code: Controller Page public class particular { public invoice__c invoices; public account accountname {get;set;} public datetime indate {get;set;} public string des {get;set;} public decimal nettotal {get;set;} public particular(ApexPages.StandardController controller) { } public PageReference save(){ invoice__c objin = new invoice__c(); objin.Account_Name__r= accountname; objin.Description__c= des; objin.invoice_Date__c=indate; insert objin; PageReference vin = new PageReference(Page.ViewInvoice.getUrl()+'?Id='+objin.Id); vin.setRedirect(true); return vin; } public Pagereference cancel(){ PageReference Pg= Page.NewInvoice; pg.setRedirect(true); return Pg; } }
Thanks in advance
Sherry !
Hi Sherry,
pls try this code
havn't tried the code, but this should work. pls let me know if this doesn't work.
Thanks,
Manohar
Thanks
I want to insert record only from Apex method instead of standard method. Please help.
public Account acct;
public particular(ApexPages.StandardController controller) {
this.acct = (Account)Controller.getRecord();
}
GIving sample for Account. You can add above code and then in the field assignment , use the API field names instead of variables (example given below). That should suffice.
Account objin = new Account();
objin.Description= acct.description;
objin.Name=acct.Name;
Hi ,
pls try this code
pls try this let me know if it workd.
Thanks,
Manohar