You need to sign in to do that
Don't have an account?
Inserting a new Record in Custom Object.
******************************
<apex:commandButton action="{!Save}" value="Save" /> // onclick of save button, a new record should be inserted
******************************
public class EmpCon {
String[] YOE = new String[]{};
String[] Desg = new String[]{};
EmpInfo__c emp;
String Id=System.currentPageReference().getParameters().get('IDInput');
String name=System.currentPageReference().getParameters().get('NameInput');
String add=System.currentPageReference().getParameters().get('AddInput');
String phone=System.currentPageReference().getParameters().get('PhoneInput');
String dob=System.currentPageReference().getParameters().get('DOBInput');
String doj=System.currentPageReference().getParameters().get('DOJInput');
String exp=System.currentPageReference().getParameters().get('ExpInput');
String desg1=System.currentPageReference().getParameters().get('DesgInput');
String skill=System.currentPageReference().getParameters().get('SkillInput');
public PageReference Save() {
PageReference curPage = System.currentPageReference();
EmpInfo__c emp;
emp = new EmpInfo__c(ID__c ='Id', Name__c='name', Address__c='add', Phone__c='phone', Years_Of_Experience__c='exp', Designation__c='desg1', Skills__c='skill');
try
{
insert emp; // here is the problem... how should insert a new record???
}catch (DmlException e) {
System.debug(e.getMessage());
}
return null;
}
**************
Same problem occurs for Update
If TestExtranet__c is your custom object and Name__c, Extranet_Name__c and URL__ c are your fields in the custom object insert a new record the way I have mentioned below...
TestExtranet__c co = new TestExtranet__c();
co.Name__c = "hello";
co.Extranet_Name__c = "google.com";
co.URL__c="google.com";
insert co;
but the code that u helped me with worked but its for inserting value hard core...
in my case, there is a page where in when i feed in the values in respective textbox and select respective options from drop down list and finally click on SAVE button, the value should get inserted into corresponding fields of custom object.
thanks for concern.
did u ever get it resolved ...I am also trying to get values from the form input apex field....in overrided SAVE() function to insert a record.. but i am not able to get field values in my custom extension class.
do you know any method to read field values?
System.currentPageReference().getParameters().get('formfirstname') is NOT working ..
also ApexPage.currentPage().getParameters().get('formfirstname') too is not working.
It is working & I checked by taking one demo example...
I have one problem that when the value get inserted thereafter the values are there in text box but gets highlighted so how to remove text from textbox when the value get inserted instead of highlight....
I inserted value into the custom object but on the same page I need that when i insert value into object as name field then at the bottom i need thank you username so how can i achieve that....
Regards....