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
Cesar Ramirez Vasquez005391619375684564Cesar Ramirez Vasquez005391619375684564 

Get value of an input field on the controller to update an object. How can i achieve this ?

In my VF page i have a function that allows the user to select the lookup field that he wants and fill an input field (this action works like a charm); after that i have a command link that updates the record but im unable to get the value from the input field, the value is always null. How can i achieve this ? I have been stuck for 3 days now, i would appreciate any help. Thanks in advance.

<apex:pageBlockTable id="srch_id" value="{!Piezas}" var="o">
            <apex:column value="{!o.Name}"> <apex:facet name="header"> </apex:facet> </apex:column>          
            <apex:column value="{!o.Producto__r.Name}"> <apex:facet name="header"> </apex:facet> </apex:column>
            <apex:column value="{!o.Bodega__c}"> <apex:facet name="header"> </apex:facet> </apex:column>
            <apex:column value="{!o.Estado__c}"> <apex:facet name="header"></apex:facet> </apex:column>
            <apex:column value="{!o.Reparaci_n_ETL__c}"> <apex:facet name="header"> </apex:facet> </apex:column>
            <apex:column headerValue="Opciones" >
                   ---------------------------------------------------This is the value im trying to get--------------------------------------------------
                  <apex:inputField id="Reparacion" value="{!PI.Reparaci_n_ETL__c}" />

                    <apex:commandLink value="Agregar a Reparacion" action="{!actualizaPieza}">
                            <apex:actionSupport event="onclic"/>    
                            <apex:param name="namePieza"   assignTo="{!piezaActual}" value="{!o.Name}"  />
                            <apex:param name="rep" assignTo="{!idRep}" value="{!PI.Reparaci_n_ETL__c}"  />


public class addPiezaController {

public String order {get; set;}
public List<Pieza__c> Piezas = new List<Pieza__c>();
public String piezaActual {get; set;}
public String idRep {get; set;}

private Pieza__c PI = new Pieza__c();

public void setPI(Pieza__c value) {
    PI = value;

public Pieza__c getPI() {
    return PI;

public PageReference lol(){
System.debug(LoggingLevel.Error, 'Reparacion ID:' + PI.Reparaci_n_ETL__c);
return null;

public addPiezaController (){
order = '';
Piezas = null;
piezaActual = '';

public List<Pieza__c> getPiezas(){

Piezas = [select Name, Producto__r.Name, Bodega__c, Estado__c, Reparaci_n_ETL__c from Pieza__c where Orden__r.Name =: order ];

return Piezas;

public void actualizaPieza(){

//Id repID = ApexPages.currentPage().getParameters().get('idRep');
System.debug(LoggingLevel.Error, 'Reparacion lololo param:' + idRep );
System.debug(LoggingLevel.Error, 'Reparacion ID:' + PI.Reparaci_n_ETL__c);
System.debug(LoggingLevel.Error, 'Name:' + piezaActual);

Pieza__c P = [select name, Reparaci_n_ETL__c, Estado__c  from Pieza__c where name =: piezaActual];
P.Reparaci_n_ETL__c = PI.Reparaci_n_ETL__c;
P.Estado__c = 'Utilizada en reparación';



Christoph EschweilerChristoph Eschweiler

I tried to replicate the situation you described but was not successful.
What I did not understand is this:

You have a custom object 'Pieza__c'. On your page you have a list of several 'Pieza__c' objects and one master(?) 'Pieza__c' object.
You display the list of objects and have an input field in each row that contains the value of the custom field ' Reparaci_n_ETL__c' of the "master" object.

Then you have a command link in each row to set the value of 'idRep' to whatever is set in the input field. This is what confuses me. If I understood you correctly, you'd have multiple input fields to set one value (see attached image)?
User-added image

That does not make sense from my point-of-view because whenever you click that command link, only the value from the last input field will be submitted to your controller...

Could you explain this a little more to me, so I might be able to help :)

Best regards,

Cesar Ramirez Vasquez005391619375684564Cesar Ramirez Vasquez005391619375684564
Hi Christoph thank you for your reply ! Thats correct i have multiple input fields and command links but i just one to update the field Reparaci_n_ETL__c of the record i hit the command link, thats because for information the user needs to see all "Pieza__c"records associated with a single "Order__c "and thus go one by one modifying the desired.
Christoph EschweilerChristoph Eschweiler

okay, so you want to be able to edit every "Reparaci_n_ETL__c" for each "Pieza__c" in each row, right?
In that case, why do you want to update every record on its own?

I'd suggest you just add a save button to the page and then, when your users are done editing each "Reparaci_n_ETL__c" field, they press save an the entire list is saved at once.
Wouldn't that solve your AJAX issues?

Best regards,