You need to sign in to do that
Don't have an account?
Div403
Insert Record into custom Object
Hi All,
I have created a new apex class and vf page to insert data into a custom object. I am able to insert record in custom object but values are not displaying in record which i have given in vf page.
Kindly help me to solve this
VF Page
<apex:page standardcontroller="Claims__c" extensions="NotesController11">
<apex:form>
<h1 style="font-size:30px"><Center> Reinsurance Verification</center> </h1>
<apex:pageBlock id="Details">
<apex:pageBlockSection columns="2" title="Company Information">
<apex:inputfield value="{!Test.Claim_Numbers__c}"/>
</apex:pageBlockSection>
</apex:pageBlock>
<apex:outputPanel layout="block">
<apex:commandButton value="Save and Close" action="{!Save}" immediate="true" />
</apex:outputPanel>
</apex:form>
</apex:page>
Apex Controller
public class NotesController11 {
public Claims__c Test{get; set;}
public NotesController11(ApexPages.StandardController controller) {
test= new Claims__c();
}
public PageReference Save() {
Claims__c rv = new Claims__c();
rv.Claim_Numbers__c= Test.Claim_Numbers__c;
insert rv;
PageReference Page = new PageReference('/'+rv.id);
Page.setRedirect(true);
return Page;
}
}
Output:
I have created a new apex class and vf page to insert data into a custom object. I am able to insert record in custom object but values are not displaying in record which i have given in vf page.
Kindly help me to solve this
VF Page
<apex:page standardcontroller="Claims__c" extensions="NotesController11">
<apex:form>
<h1 style="font-size:30px"><Center> Reinsurance Verification</center> </h1>
<apex:pageBlock id="Details">
<apex:pageBlockSection columns="2" title="Company Information">
<apex:inputfield value="{!Test.Claim_Numbers__c}"/>
</apex:pageBlockSection>
</apex:pageBlock>
<apex:outputPanel layout="block">
<apex:commandButton value="Save and Close" action="{!Save}" immediate="true" />
</apex:outputPanel>
</apex:form>
</apex:page>
Apex Controller
public class NotesController11 {
public Claims__c Test{get; set;}
public NotesController11(ApexPages.StandardController controller) {
test= new Claims__c();
}
public PageReference Save() {
Claims__c rv = new Claims__c();
rv.Claim_Numbers__c= Test.Claim_Numbers__c;
insert rv;
PageReference Page = new PageReference('/'+rv.id);
Page.setRedirect(true);
return Page;
}
}
Output:
HI,
Please share the debug log., so that we can see if any workflow rules/triggers were clearing this field off or if anything is going wrong !
Thanks,
Balaji
Thanks for the response
Here is the controller and its debug log
Apex Controller
public class NotesController11 {
public Claims__c Test{get; set;}
public NotesController11(ApexPages.StandardController controller) {
test= new Claims__c();
system.debug('testcontroller' +test);
}
public PageReference Save() {
System.debug('Enter save----');
Claims__c rv = new Claims__c();
rv.Claim_Numbers__c= Test.Claim_Numbers__c;
System.debug('ClaimNumberforrv' +rv.Claim_Numbers__c);
System.debug('ClaimNumberfortest' +test.Claim_Numbers__c);
insert rv;
PageReference Page = new PageReference('/'+rv.id);
Page.setRedirect(true);
return Page;
}
}
Yeah! i see the issue now! can you remove, the immediate="True" property from, Command Button tag? What it is doing is, it is making the method to fire way before the value of the text field being set to the variable.
Hope it works
Thanks,
balaji
rv.Claim_Numbers__c= System.currentPageReference().getParameters().get('j_id0:j_id1:Details:j_id3:j_id4');
mark as resolved if helpful