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
satheesh8.k1.3890099515516848E12satheesh8.k1.3890099515516848E12 

Visualforce Error

Visual force Code:

<apex:page standardController="Contact" sidebar="false" showHeader="false" docType="html-5.0" applyHtmlTag="true" applyBodyTag="true" extensions="MyResponsiveForm1">    
<html>  
<head>


    <!-- Style-->
    <style>  
//Custom Error Message    
.errorStyle, .errorMsg, .importantWarning {    
        color: #d74c3b;
    }   
.requiredBlock {    
    background-color: #c00;
    position: absolute;
    width: 3px;
    height: 48px;
}    

.extraSpaceBelow{    
    margin-bottom:20px;
}            
.myMultiClass{           
  display: block;
  font-size: 14px;
  line-height: 1.42857143;
  color: #555;
  border: 1px solid #ccc;
  border-radius: 4px;  
}
.myMultiClass:focus {
  border-color: #66afe9;
  outline: 0;
  -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, .6);
          box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, .6);
}   
.sf1button {    
font-size: 16px;
color: #44596c;
text-shadow: none;
margin: 0;
padding: 4px 14px;
height: 35px;
font-size: 16px;
font-family: 'ProximaNovaSoft-Regular';
font-weight: normal;
border: 1px solid #bbc0c4;
border-radius: 5px;
background: -moz-linear-gradient(#ffffff,#f1f1f1);
background: -webkit-linear-gradient(#ffffff,#f1f1f1);
background: -ms-linear-gradient(#ffffff,#f1f1f1);
background: linear-gradient(#ffffff,#f1f1f1);
box-shadow: none;
text-align: center;
cursor: pointer;
box-sizing: border-box;
}   

.sf1button:active {   
background: #e9e9e9;   
}   
</style>    


    <!-- MultiSelect Picklsit-->  
        <script type="text/javascript">
        var $j = jQuery.noConflict();
        $j(document).ready(function() {
            setTimeout(function() {
                $j('select.myMultiClass').each(function(i, val) { 
                    $j(val).width(110);
                    $j(val).height(110);
                })
            },100);
        });
       </script>


<apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></apex:includeScript>      
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css"/>
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap-theme.min.css"/>
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>

</head>
<body>

<form name="userForm" novalidate="novalidate" >



    <div class="row clearfix">
        <div class="col-md-12 column" id="section1">
            <div class="panel list-group">                        
                <a class="list-group-item active" href="#collapsePersonalInformation" data-toggle="collapse" data-parent="#section1">Personal Information</a>
                <div id="collapsePersonalInformation" class="panel-collapse collapse">
                <br/>            
                    <apex:form >       


                    <apex:outputPanel id="firstPanel"  rendered="{!firstPanel}">                             
                    <div class="row">  

                        <apex:repeat value="{!$ObjectType.Contact.FieldSets.properNames}" var="f">
                            <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12 extraSpaceBelow">  
                                <div class="col-sm-4"><apex:outputlabel value="{!f.Label}"></apex:outputlabel> </div>                                    
                                <div class="col-sm-8"><apex:outputField styleClass="form-control" value="{!Contact[f.fieldPath]}" /></div>

                            </div>        

                        </apex:repeat> 
                            <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12 extraSpaceBelow">
                                <div class="col-sm-4"><apex:outputLabel >Testq Without Bootstrap style</apex:outputLabel></div>
                                <div class="col-sm-8"><apex:outputField value="{!Contact.Working_Days__c}" styleClass="myMultiClass"/></div>
                            </div>




                    </div> 

                    <apex:commandButton value="Edit" action="{!firstButton}"/>

                    </apex:outputPanel>


                    <apex:outputPanel id="secondPanel"  rendered="{!secondPanel}">


                    <div class="row">  

                        <apex:repeat value="{!$ObjectType.Contact.FieldSets.properNames}" var="f">
                            <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12 extraSpaceBelow">  
                                <div class="col-sm-4"><apex:outputlabel value="{!f.Label}"></apex:outputlabel> </div>                                    
                                <div class="col-sm-8"><apex:inputField styleClass="form-control" value="{!con[f.fieldPath]}" required="{!OR(f.required, f.dbrequired)}"/></div>

                            </div>        

                        </apex:repeat> 
                            <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12 extraSpaceBelow">
                                <div class="col-sm-4"><apex:outputLabel >Testq Without Bootstrap style</apex:outputLabel></div>
                                <div class="col-sm-8"><apex:inputField value="{!con.Working_Days__c}" styleClass="myMultiClass"/></div>
                            </div>




                    </div> 
                    <apex:commandButton action="{!save}"  value="Submit"  />
                    </apex:outputPanel>

                    </apex:form>                                                
                </div>

            </div>
        </div>
    </div>


    <div class="row clearfix">
        <div class="col-md-12 column" id="section1">
            <div class="panel list-group">                        
                <a class="list-group-item active" href="#collapsePersonalInformation" data-toggle="collapse" data-parent="#section1">PF1</a>
                <div id="collapsePersonalInformation1" class="panel-collapse collapse">
                <br/>            
                    <apex:form >       


                    <apex:outputPanel id="ss"  rendered="{!ss}">                             
                    <div class="row">  

                        <apex:repeat value="{!$ObjectType.Contact.FieldSets.properNames}" var="f">
                            <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12 extraSpaceBelow">  
                                <div class="col-sm-4"><apex:outputlabel value="{!f.Label}"></apex:outputlabel> </div>                                    
                                <div class="col-sm-8"><apex:outputField styleClass="form-control" value="{!Contact[f.fieldPath]}" /></div>

                            </div>        

                        </apex:repeat> 
                            <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12 extraSpaceBelow">
                                <div class="col-sm-4"><apex:outputLabel >Testq Without Bootstrap style</apex:outputLabel></div>
                                <div class="col-sm-8"><apex:outputField value="{!Contact.Working_Days__c}" styleClass="myMultiClass"/></div>
                            </div>




                    </div> 

                    <apex:commandButton value="Edit" action="{!sss}"/>

                    </apex:outputPanel>


                    <apex:outputPanel id="ss1"  rendered="{!ss1}">


                    <div class="row">  

                        <apex:repeat value="{!$ObjectType.Contact.FieldSets.properNames}" var="f">
                            <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12 extraSpaceBelow">  
                                <div class="col-sm-4"><apex:outputlabel value="{!f.Label}"></apex:outputlabel> </div>                                    
                                <div class="col-sm-8"><apex:inputField styleClass="form-control" value="{!con[f.fieldPath]}" required="{!OR(f.required, f.dbrequired)}"/></div>

                            </div>        

                        </apex:repeat> 
                            <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12 extraSpaceBelow">
                                <div class="col-sm-4"><apex:outputLabel >Testq Without Bootstrap style</apex:outputLabel></div>
                                <div class="col-sm-8"><apex:inputField value="{!con.Working_Days__c}" styleClass="myMultiClass"/></div>
                            </div>




                    </div> 
                    <apex:commandButton action="{!sss1}"  value="Submit"  />
                    </apex:outputPanel>

                    </apex:form>                                                
                </div>

            </div>
        </div>
    </div>




    </form>
    </body>
    </html>


</apex:page>


Apex  code: 

public with sharing class MyResponsiveForm1 {    



    public boolean firstPanel{get;set;}
   public boolean secondPanel{get;set;}
   public boolean firstPanel1{get;set;}
   public boolean secondPanel1{get;set;}
   public contact con{get;set;}

   public boolean ss{get;set;}
   public boolean ss1{get;set;}
    public MyResponsiveForm1(ApexPages.StandardController controller) {
        con=(Contact)controller.getRecord();
        firstPanel = true;
        ss= true;
    }
    public PageReference edit() {
         firstPanel=false;
      secondPanel= true;
      return null;
    }
    public PageReference save() {
        update con;
         firstPanel=true;
      secondPanel=false;
      return null;

    }
    public void sss1() {
        update con;
         ss=true;
      ss1=false;


    }
    public void firstButton()
    {
      firstPanel=false;
      secondPanel= true;

    }
    public void sss()
    {
      ss=false;
      ss1= true;

    }



}



this code working good but edit the record then click the submit button which gives some error:

System.DmlException: Update failed. First exception on row 0; first error: MISSING_ARGUMENT, Id not specified in an update call: []
Error is in expression '{!save}' in component <apex:commandButton> in page boostrapdemo: Class.MyResponsiveForm1.save: line 24, column 1
Class.MyResponsiveForm1.save: line 24, column 1


please give me solution for this

Thanks
Satheesh
Best Answer chosen by satheesh8.k1.3890099515516848E12
Jigar.LakhaniJigar.Lakhani
Hi,

Above error is because of you are updating contact without Id field, are you passing contact id in URL for that visualforce page?
Can you give me that URL, which you are using.

If URL is fine, then you need to update constructor and save method like below.

Constructor:
public MyResponsiveForm1(ApexPages.StandardController controller) {
	con = (Contact)controller.getRecord();
	List<Contact> listContacts = new List<Contact>([SELECT Id,Name,FirstName,LastName,Email....all fields which in fieldsets FROM Contact WHERE Id =: con.Id Limit 1]);
	if (listContacts != null && listContacts.size() > 0) {
		con = listContacts[0];
	}
	firstPanel = true;
	ss= true;
}
Save Method:
public PageReference save() {
	if (con != null && con.Id != null) {
		update con;
	}
	firstPanel=true;
	secondPanel=false;
	return null;
}

Thanks & Cheers,
Jigar


 

All Answers

Jigar.LakhaniJigar.Lakhani
Hi,

Above error is because of you are updating contact without Id field, are you passing contact id in URL for that visualforce page?
Can you give me that URL, which you are using.

If URL is fine, then you need to update constructor and save method like below.

Constructor:
public MyResponsiveForm1(ApexPages.StandardController controller) {
	con = (Contact)controller.getRecord();
	List<Contact> listContacts = new List<Contact>([SELECT Id,Name,FirstName,LastName,Email....all fields which in fieldsets FROM Contact WHERE Id =: con.Id Limit 1]);
	if (listContacts != null && listContacts.size() > 0) {
		con = listContacts[0];
	}
	firstPanel = true;
	ss= true;
}
Save Method:
public PageReference save() {
	if (con != null && con.Id != null) {
		update con;
	}
	firstPanel=true;
	secondPanel=false;
	return null;
}

Thanks & Cheers,
Jigar


 
This was selected as the best answer
satheesh8.k1.3890099515516848E12satheesh8.k1.3890099515516848E12
Hi..Jiger

Thanks for given this reply . your code is working fine  .

Thanks 
Satheesh