You need to sign in to do that
Don't have an account?
TharunKumar 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
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
Change your query like below,
SELECT Name FROM Job_Application__c WHERE Job_Position__c = :selectedposition
I tried that but it is not working.Selected position property is returning Id so i need to match that with ID.
<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>
Your query should be like You are using Job_Position__c.Id you just need Id there.
Try and let us know.
Create a set of Ids and add the Id to set and use following
And use the following query
Have a debug on selectedposition and see what is the value if the id is not passed then have a look.