You need to sign in to do that
Don't have an account?
Dynamic Query
Hi I am getting vf page error saying that id Not specifeid in update call. i got the record values using dynamic query into vf as inputfeild.when try to update the values on click of UpdateBarcode geting the error.
Vf :
===========================
<apex:page controller="Cls_Update_Size" sidebar="false" showHeader="false" >
<apex:form >
<apex:pageBlock id="repeat" >
<div style="margin:10px 300px 10px 400px"><h3 style="margin:10px 10px 10px 2px">Enter Barcode</h3><br/>
<apex:inputText value="{!Barcode}" size="40"/>
<apex:pageMessages />
</div><br/><hr/>
<apex:panelGrid >
<apex:facet name="header">Select the Feilds to Update</apex:facet>
<table style="margin:0px 0px 0px 0px">
<apex:repeat value="{!Warpmthd}" var="c" id="table" >
<td><apex:inputCheckbox value="{!c.selected}"/>
<apex:outputlabel value="{!c.fl.Label}"/> </td>
</apex:repeat><br/><br/><br/>
</table>
<table>
<apex:repeat value="{!fields}" var="f">
<tr>
<td>
<strong> <apex:outputlabel value="{!f.label}" /></strong> </td> <td> <apex:inputField value="{!feildvalue[f.fieldPath]}" />
</td>
</tr>
</apex:repeat>
</table>
<apex:commandButton action="{!UpdateEntered}" value="Update" style="margin:30px 0px 10px 100px" />
</apex:panelGrid>
<div style="margin:10px 0px 30px 1100px" ><br/><br/>
<apex:commandButton action="{!Find}" value="Find" rerender="repeat"/>
<apex:commandButton action="{!Oknext}" value="Ok and Next"/>
<apex:commandButton action="{!Close}" value="Close"/>
</div>
</apex:pageBlock>
</apex:form>
</apex:page>
Class:
======================================================================================
public class Cls_Update_Size {
public boolean updateButton { get; set; }
public String inputSection { get; set; }
public PageReference UpdateEntered(){
system.debug('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'+feildvalue);
update feildvalue;
return null;
}
public Samples_Mgmt__c feildvalue{ get; set; }
Public Id SamId=null;
Public Id OffId=null;
public Samples_Mgmt__c sample;
public string size;
list<Samples_Mgmt__c> lstsam= new list<Samples_Mgmt__c>();
list<offer__c> lstoff= new list<offer__c>();
public String Barcode { get; set;}
public list<wrap> lstwrap {get; set;}
List<Schema.FieldSetMember> lstFieldSetMember =new List<Schema.FieldSetMember>();
List<Schema.FieldSetMember> selectedFeilds = new List<Schema.FieldSetMember>();
public Cls_Update_Size(){
lstsam=[select id,Bar_Code__c from Samples_Mgmt__c];
lstFieldSetMember.addall(SObjectType.Samples_Mgmt__c.FieldSets.Search_Barcode.getFields());
lstwrap=new List<wrap>();
}
public PageReference Find(){
updateButton =true;
selectedFeilds.clear();
for(wrap w: getWarpmthd()) {
if(w.selected == true) {
selectedFeilds.add(w.fl);
}
}
feildvalue=new Samples_Mgmt__c();
system.debug('******************************'+getFeildvalues());
feildvalue=getFeildvalues();
lstwrap.clear();
return null;
}
public Samples_Mgmt__c getFeildvalues(){
SamId='a0UK0000001jFOz';
String query = 'SELECT ';
for(Schema.FieldSetMember f : this.getFields()) {
query += f.getFieldPath() + ', ';
}
query += 'Id, Name FROM Samples_Mgmt__c where id=:SamId';
return Database.query(query);
}
public List<Schema.FieldSetMember> getFields(){
return selectedFeilds;
}
public List<wrap> getWarpmthd(){
for(Schema.FieldSetMember mem :lstFieldSetMember){
lstwrap.add(new wrap(mem));
}
return lstwrap;
}
Public class Wrap{
public Boolean selected{get; set;}
public Schema.FieldSetMember fl{get; set;}
public Wrap(Schema.FieldSetMember m){
selected = false;
fl=m;
}
}
}
Thanks in advance...
Hi Sri,
Can you post your debug statement at line before update i.e.
system.debug('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'+feildvalue);
Seems like the fieldvalue you are attempting to update does not have Id field with it.
Regards,
Prafull
Thanks For your Reply..And this my Debug log Output.
|01pK0000000AfMm|Cls_Update_Size invoke(UpdateEntered)
06:00:15.081 (81913000)|METHOD_ENTRY|[8]|01pK0000000AfMm|Cls_Update_Size.__sfdc_feildvalue()
06:00:15.081 (81943000)|METHOD_EXIT|[8]|01pK0000000AfMm|Cls_Update_Size.__sfdc_feildvalue()
06:00:15.081 (81967000)|SYSTEM_METHOD_ENTRY|[8]|String.valueOf(Object)
06:00:15.081 (81977000)|SYSTEM_METHOD_EXIT|[8]|String.valueOf(Object)
06:00:15.082 (82001000)|SYSTEM_METHOD_ENTRY|[8]|System.debug(ANY)
06:00:15.082 (82010000)|USER_DEBUG|[8]|DEBUG|@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@null
06:00:15.082 (82019000)|SYSTEM_METHOD_EXIT|[8]|System.debug(ANY)
06:00:15.082 (82029000)|METHOD_ENTRY|[9]|01pK0000000AfMm|Cls_Update_Size.__sfdc_feildvalue()
06:00:15.082 (82046000)|METHOD_EXIT|[9]|01pK0000000AfMm|Cls_Update_Size.__sfdc_feildvalue()
06:00:15.082 (82129000)|EXCEPTION_THROWN|[9]|System.NullPointerException: Attempt to de-reference a null object
06:00:15.082 (82278000)|FATAL_ERROR|System.NullPointerException: Attempt to de-reference a null object
Class.Cls_Update_Size.UpdateEntered: line 9, column 1
06:00:15.082 (82289000)|CODE_UNIT_FINISHED|Cls_Update_Size invoke(UpdateEntered)
Please make sure that you get the record to update with Id specified.
Regards,
Iam able to populate values in vf page as inputfeilds. But when i try to get the values from vf to controller it was showing null.
i Used Feildvalue property to set and get the values..