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
Aladdin USAladdin US 

record is not inserting

when i clinkon save record isno inserting into the respective object

public class Android
{
   public and__c p {set;get;}
 
    
    public string ConstructionCost       {set;get;}
    public boolean FireSafety        {set;get;}
    }

    public android()
    {
       p=new android__c();
    }
    
        public List<SelectOption> getItems()
    {
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('None','None'));
        options.add(new SelectOption('Commercial','Commercial'));
        options.add(new SelectOption('Residential','Residential'));
        return options;
    }

    
    public void save()
    {
           integer i=0;
        
       
        p.Construction_Cost__c=ConstructionCost;
        p.Fire_Safety__c=FireSafety;
        
        insert p;


VF:

<div>
        <apex:commandButton value="save" action="{!save}" styleclass="button"  />
    </div>

Can anyone tell me please.

Thanks.
Raj VakatiRaj Vakati
Looks like the required field is missing like name and etc  .. 

Can you please add the debug logs and see what it is printing 
 
public void save()
    {
           integer i=0;
        
       
        p.Construction_Cost__c=ConstructionCost;
        p.Fire_Safety__c=FireSafety;
        
        insert p;
System.debug('p'+p);
		
	}


 
ApuroopApuroop
Use the try catch blocks. For example:
 
Account[] accts = new Account[]{new Account(billingcity = 'San Jose')};
try {
    insert accts;
} catch (System.DmlException e) {
    for (Integer i = 0; i < e.getNumDml(); i++) {
        // Process exception here
        System.debug(e.getDmlMessage(i)); 
    }
}

 
Aladdin USAladdin US
Hi raja,

    Debug log is empty not showing any thing.

Thanks.
Raj VakatiRaj Vakati
Its saving successfully that why its not printing any values 
 
Account[] accts = new Account[]{new Account(billingcity = 'San Jose')};
try {
    insert accts;
System.debug('insted account'+accts) ; 

} catch (System.DmlException e) {
    for (Integer i = 0; i < e.getNumDml(); i++) {
        // Process exception here
        System.debug(e.getDmlMessage(i)); 
    }
}