I have a VF page with a table populated by a wrapper class and some lookup inputs above it.

I've created a method to update a column value for all the table rows to match whatever is selected in the input above but it appears that apex:param is passing the value of the lookup field as displayed (e.g. 'Test Course') rather than the stored Id.

I've added a SOQL query to get the Id based on the Name being passed via apex:param so this code does achieve exactly what I'm trying to do - but I'm wondering if there's a way to do this without the extra query.

I've looked through all the docs and previous answers I can find but there doesn't seem to be anything that addresses this specific situation.

Group Input

<apex:column headerValue="Set Course for All">

        <apex:param name="groupSC" value="" assignTo="{!groupCourse}" />


<apex:pageBlockTable value="{!wrappers}" var="wrapper" id="wtable">
    <apex:column headerValue="First Name">
         <apex:inputText value="{!wrapper.firstName}" />
            <apex:column headerValue="Last Name">
                <apex:inputText value="{!wrapper.lastName}" />
            <apex:column headerValue="Course">


public void updateAllCourses() {

    List<Course__c> tempCourse = [
        SELECT Id
        FROM Course__c
        WHERE Name = :groupCourse
    Id courseId = tempCourse[0].Id;
    for (Integer i = 0; i < wrappers.size(); i++) {
        wrappers[i].bk.Course__c = courseId;

tl;dr Is there a way to get apex:param to pass the Id of a record chosen in an input field instead of the Name of the field?

Thanks in advance for your help!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.