Can u tell me 1 thing more. How to capture the value of the lookup from the code.
I wrote like this.
public with sharing class assigned_consultant
{
public String selectItem { get; set; }
public PageReference savedata()
{
System.debug('++++++++++++++++++++' );
return null;
}
public assigned_consultant__C getAssg()
{
return null;
}
I have an object assigned_consultant__C . That I have created the lookup for the Contact__c. When we select the lookup the value which is selected by the lookup. I want that value for the quarry execution.
My question is how to get the selected value of the lookup field. In the Controller.
public with sharing class assigned_consultant
{
// public assigned_consultant__C sample;
// String contact = null;
list<string> contact = new list<contact>();
public String selectItem { get; set; }
public assigned_consultant__C getAssg()
{
// sample = [select End_date__c, Project__c, Start_date__c from assigned_consultant__c where Id = :ApexPages.currentPage().getParameters().get('Assg')];
return null;
}
public void savedata()
{
contact = [select End_date__c, Project__c, Start_date__c from assigned_consultant__c where Contact__c = :assg.Contact__c];
System.debug('++++++++++++++++++++');
}
Yes you can do that
//Controller class
public class myClass
{
public assigned_consultant__c aCons {get; set;}
}
//Visualforce Page
All Answers
You create a look up using
<apex:inputField value="{!objectName.LookupField}"/>
Thanks
Hi
I am new to salesforce. Can u tell me is this the way to write.
My code. I am getting error
Error: Unknown property 'ContactStandardController.assigned_consultant__c'
thanks
Anuraj
Change
<apex:page standardController="Contact">
to
<apex:page standardController="assigned_consultant__c">
Hi
I want to use Controller. Can I do it using Controller.
Thanks that was successful.
Thanks
Anuraj
Yes you can do that
//Controller class
public class myClass
{
public assigned_consultant__c aCons {get; set;}
}
//Visualforce Page
Thank you very much.
Hi
Can u tell me 1 thing more. How to capture the value of the lookup from the code.
I wrote like this.
Thanks
Anuraj
Can you further explain your question please?
I have an object assigned_consultant__C . That I have created the lookup for the Contact__c. When we select the lookup the value which is selected by the lookup. I want that value for the quarry execution.
My question is how to get the selected value of the lookup field. In the Controller.
You can use as it is
Seletc Id from Object where Field = : aCons.Contact__c
For better results put a null check on that fields before executing the query
I have don like this but their is error
Error: assigned_consultant Compile Error: Variable does not exist: assg.Contact__c at line 17 column 114
what changes should i make in it.
public assigned_consultant__C getAssg() should be changed to
public assigned_consultant__C assg(get{//query here}; set;)
it should work then
It is showing the
Error: assigned_consultant Compile Error: unexpected token: '{' at line 7 column 44