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

Apex code not working. record not saving when i click on save button
Hi,
When I am saving my record i am getting this Error:
Attempted to upsert a null list
Error is in expression '{!save}' in component <apex:commandButton> in page brandpage: Class.Brandvfcontroller.save: line 15, column 1
here i am attaching my Apex code and VFcode. please correct it...
Thanks in Advance
When I am saving my record i am getting this Error:
Attempted to upsert a null list
Error is in expression '{!save}' in component <apex:commandButton> in page brandpage: Class.Brandvfcontroller.save: line 15, column 1
here i am attaching my Apex code and VFcode. please correct it...
Thanks in Advance
public with sharing class Brandvfcontroller { public METADATA_Brand__c bran; public void insertBrandvfcontroller(){ bran = [SELECT Id, Name, BRAND_ABBR__c,BRAND_CODE__c,BRAND_END_DATE__c,BRAND_ID__c,BRAND_START_DATE__c, DEFAULT_CAMPAIGN__c,Description__c,DISPLAY_FLAG__c,DISPLAY_SEQUENCE__c,Franchise__c,FRANCHISE_ID__c, SRC_SYS_KEY__c,STATUS__c FROM METADATA_Brand__c WHERE Id =: ApexPages.currentPage().getParameters().get('id')]; } public METADATA_Brand__c getbran(){ return bran; } public PageReference save() { Upsert bran; PageReference pref = new ApexPages.StandardController(bran).view(); return pref; } }
<apex:page controller="Brandvfcontroller" 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="Brand"> <apex:outputPanel styleClass="blue" > <apex:pageblockSection title="Brand Details" columns="2" collapsible="false"> <apex:inputField value="{!bran.Name}"/> <apex:inputField value="{!bran.Franchise__c}"/> <apex:inputField value="{!bran.BRAND_ABBR__c}"/> <apex:inputField value="{!bran.BRAND_CODE__c}"/> <apex:inputField value="{!bran.Description__c}"/> <apex:inputField value="{!bran.BRAND_ID__c}"/> <apex:inputField value="{!bran.BRAND_END_DATE__c}"/> <apex:inputField value="{!bran.BRAND_START_DATE__c}"/> <apex:inputField value="{!bran.DEFAULT_CAMPAIGN__c}"/> <apex:inputField value="{!bran.DISPLAY_FLAG__c}"/> <apex:inputField value="{!bran.DISPLAY_SEQUENCE__c}"/> <apex:inputField value="{!bran.FRANCHISE_ID__c}"/> <apex:inputField value="{!bran.SRC_SYS_KEY__c}"/> <apex:inputField value="{!bran.STATUS__c}"/> </apex:pageblockSection> </apex:outputPanel> <apex:pageBlockButtons location="bottom" > <apex:commandButton value="Save" action="{!save}"/> </apex:pageBlockButtons> </apex:pageBlock> </apex:form> </apex:page>
if(bran.size != null && bran.size() > 0)
upsert bran ;
Hi Depak, Its giving Error.
if(bran != null )
upsert bran ;