You need to sign in to do that
Don't have an account?

Apex code not working.. record not saving
<apex:page standardcontroller="METADATA_Campaign__c" extensions="CampaignPage" showHeader="false" sidebar="false"> <style> body .bPageBlock .pbBody .red .pbSubheader{ background-color:#c00000; } body .bPageBlock .pbBody .grey .pbSubheader{ background-color:#c0c0c0; } body .bPageBlock .pbBody .grey .pbSubheader h3{ color:#000; } body .bPageBlock .pbBody .blue .pbSubheader{ background-color:#0000FF; } </style> <apex:form > <apex:pageBlock title="Campaign Details"> <apex:outputPanel styleClass="Red" > <apex:pageblockSection title="Campaign Information"> <apex:inputField value="{!camp.Name}"/> <apex:inputField value="{!camp.BRANDED__c}"/> <apex:inputField value="{!camp.METADATA_Status__c}"/> <apex:inputField value="{!camp.Program__c}"/> <apex:inputField value="{!camp.Therapy_Class__c}"/> <apex:inputField value="{!camp.Campaign_Code__c}"/> <apex:inputField value="{!camp.Campaign_ID__c}"/> <apex:inputField value="{!camp.Campaign_Type__c}"/> <apex:inputField value="{!camp.EndDate__c}"/> <apex:inputField value="{!camp.HCP__c}"/> <apex:inputField value="{!camp.Objective__c}"/> <apex:inputField value="{!camp.Description__c}"/> <apex:inputField value="{!camp.Program_ID__c}"/> <apex:inputField value="{!camp.StartDate__c}"/> <apex:inputField value="{!camp.Status__c}"/> <apex:inputField value="{!camp.Therapy_ClassID__c}"/> <apex:inputField value="{!camp.UA_CAMPAIGN_ID__c}"/> <apex:inputField value="{!camp.USMM__c}"/> </apex:pageblockSection> </apex:outputPanel> <apex:pageBlockButtons > <apex:commandButton value="Save" action="{!save}"/> </apex:pageBlockButtons> </apex:pageBlock> </apex:form> </apex:page> // Above VF Page is my Custom page, when i click sava the record not saving and showing error that 'Attempted to upsert a null list Error is in expression '{!save}' in component <apex:commandButton> in page metadatacampaignpage: Class.CampaignPage.save: line 14, column 1 here i am attaching my Apex class please saove this... Its urgent.. Thanks in Advance public class CampaignPage { public CampaignPage(ApexPages.StandardController controller) { } public Metadata_Campaign__c camp; public void insertcampaign(){ camp = [select id,BRANDED__c,Campaign_Code__c,Campaign_ID__c,Campaign_Type__c,Description__c,EndDate__c,HCP__c,Objective__c,Program__c,Program_ID__c,StartDate__c, METADATA_Status__c,Status__c,Therapy_ClassID__c,Therapy_Class__c,UA_CAMPAIGN_ID__c,USMM__c from METADATA_Campaign__c where id =: ApexPages.currentPage().getParameters().get('id')]; } public Metadata_Campaign__c getcamp(){ return camp; } public system.PageReference save() { Upsert camp; PageReference pref = new ApexPages.StandardController(camp).view(); return pref; } } '
You can do this with Standard Controller only.
Try with the below code.