+ Start a Discussion
Div403Div403 

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:

User-added image
Balaji Chowdary GarapatiBalaji Chowdary Garapati
@Div403:

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
Div403Div403
Hi 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;

    }

}

User-added image
Balaji Chowdary GarapatiBalaji Chowdary Garapati
@Div403:

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
HaiderRaza77HaiderRaza77
Use the debug to get the id of the inputfield and use it in you extension to be used in the below statement


rv.Claim_Numbers__c= System.currentPageReference().getParameters().get('j_id0:j_id1:Details:j_id3:j_id4');



 
public with sharing class NotesController11 {
   public Functional_Requirement__c Test{get;set;}
   public NotesController11(ApexPages.StandardController controller) {  }
    
    public PageReference Save() {    
        Functional_Requirement__c rv = new Functional_Requirement__c();
        rv.Claim_Numbers__c= System.currentPageReference().getParameters().get('j_id0:j_id1:Details:j_id3:j_id4');
        insert rv;
        PageReference Page = new PageReference('/'+rv.id);
        Page.setRedirect(true);
        return Page;

    }

}

mark as resolved if helpful