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
TharunKumar ChadaTharunKumar Chada 

SOQL Query errror while trying to match the selected object id

Controller
public class PosAppController {

    public Id selectedposition{get;set;}
    
    public List<Job_Application__c> AppplicationDetails{get;set;}

    public List<Job_Position__c> getMypositions() {
    
        return [SELECT id,Name FROM Job_Position__c];
    }
    
    public void PositionClicked(){
    
      AppplicationDetails = [SELECT Name FROM  Job_Application__c WHERE Job_Position__c.Id = :selectedposition]; //showing error when trying to match the id 
    }

}
VisualForce Page
<apex:page controller="MyController">
  <apex:form >
    <apex:dataList value="{!myaccounts}" var="acct">
       <apex:commandLink action="{!accountclicked}" reRender="ContactDetail">
       <apex:outputText value="{!acct.name}">
       </apex:outputText>
       <apex:param name="id" value="{!acct.id}" assignTo="{!selectedAccount}"/>
       </apex:commandLink>
    </apex:dataList>
    <apex:outputPanel id="ContactDetail">
       <apex:repeat value="{!contactsInformation}" var="contact">
         <p> {!Contact.FirstName & ' ' & Contact.LastName} </p>
       
       </apex:repeat>
    </apex:outputPanel>
  </apex:form>
</apex:page>

I need to show up the job positions names on the page and clicking on each position should show up the job application names related to that position and the relationship between position and application is look-up
Thiyagarajan Selvaraj (SFDC Developer)Thiyagarajan Selvaraj (SFDC Developer)
Hi TharunKumar Chada,

Change your query like below, 

SELECT Name FROM  Job_Application__c WHERE Job_Position__c = :selectedposition

 
TharunKumar ChadaTharunKumar Chada
Hi Thiyagarajan Selvaraj,

I tried that but it is not working.Selected position property is returning Id so i need to match that with ID.
TharunKumar ChadaTharunKumar Chada
Sorry The VisualPage Code is this

<apex:page>
<apex:form >
    <apex:dataList value="{!mypositions}" var="position">
       <apex:commandLink action="{!PositionClicked}" reRender="ApplicationDetail">
           <apex:outputText value="{!position.name}">
           </apex:outputtext>
           <apex:param name="id" value="{!position.id}" assignTo="{!selectedposition}"/>
       </apex:commandLink>
    </apex:dataList>

<apex:outputPanel id="ApplicationDetail">
       <apex:repeat value="{!AppplicationDetails}" var="application">
         <p> {!application.name} </p>
       </apex:repeat>
  </apex:form>

</apex:page>
Mudasir WaniMudasir Wani
Dear,

Your query should be like
SELECT Name FROM  Job_Application__c WHERE Id = :selectedposition
You are using Job_Position__c.Id  you just need Id there.

Try and let us know.
 
TharunKumar ChadaTharunKumar Chada
Even tried that not working
Mudasir WaniMudasir Wani
Two Suggestions.

Create a set of Ids and add the Id to set and use following
 
Set<Id> myIdSet = new Set<Id>(); myIdSet.add(selectedposition);

And use the following query 
SELECT Name FROM Job_Application__c WHERE Id IN : myIdSet


Have a debug on selectedposition and see what is the value if the id is not passed then have a look.