You need to sign in to do that
Don't have an account?
Shwetal Desai
How can i fetch Id from SelectList component??
here is my code:
-----------------------------------------------------------------------------------------------------------------------
String Emps;
public String selectedEmp {get;set;}
public List EmpList;
public List getEmployees()
{
try
{
if (EmpList== null)
{
Employee__c[] emp = [select Id,Name,Employee__c,FirstName__c,Last_Name__c from Employee__c where Active__c=true ORDER BY Employee__c];
EmpList = new List();
for(Employee__c empl : emp)
{
EmpList.add(new SelectOption(empl.Id, String.valueOf(empl.Employee__c)));
}
}
return EmpList;
}
catch(Exception ex){return EmpList;}
}
public String getEmps()
{
return Emps;
}
public void setEmps(String Emps)
{
this.Emps = Emps;
}
------------------------------------------------------------------------------------------------------
Now in other function i want selected Employee's Id..
But How can i take that??
That function is :
--------------------------------------------------------------------------------------------------------------------
public PageReference saveTc()
{
Employee__c emps = [select Id,Name,Employee__c,Password__c from Employee__c where Id=:Emps];
if(emps.Password__c == psw)
{
tc.EmployeeId__c = Emps;
tc.DateTime__c = DateTime.Now();
tc.CheckIn__c = DateTime.Now();
insert tc;
}
else
{
ApexPages.Message msg= new ApexPages.Message(ApexPages.Severity.ERROR, 'Invalid Password !', 'Invalid Password !');
ApexPages.addmessage(msg);
}
return null;
}
----------------------------------------------------------------------------------------------------------------------
please help.
-----------------------------------------------------------------------------------------------------------------------
String Emps;
public String selectedEmp {get;set;}
public List EmpList;
public List getEmployees()
{
try
{
if (EmpList== null)
{
Employee__c[] emp = [select Id,Name,Employee__c,FirstName__c,Last_Name__c from Employee__c where Active__c=true ORDER BY Employee__c];
EmpList = new List();
for(Employee__c empl : emp)
{
EmpList.add(new SelectOption(empl.Id, String.valueOf(empl.Employee__c)));
}
}
return EmpList;
}
catch(Exception ex){return EmpList;}
}
public String getEmps()
{
return Emps;
}
public void setEmps(String Emps)
{
this.Emps = Emps;
}
------------------------------------------------------------------------------------------------------
Now in other function i want selected Employee's Id..
But How can i take that??
That function is :
--------------------------------------------------------------------------------------------------------------------
public PageReference saveTc()
{
Employee__c emps = [select Id,Name,Employee__c,Password__c from Employee__c where Id=:Emps];
if(emps.Password__c == psw)
{
tc.EmployeeId__c = Emps;
tc.DateTime__c = DateTime.Now();
tc.CheckIn__c = DateTime.Now();
insert tc;
}
else
{
ApexPages.Message msg= new ApexPages.Message(ApexPages.Severity.ERROR, 'Invalid Password !', 'Invalid Password !');
ApexPages.addmessage(msg);
}
return null;
}
----------------------------------------------------------------------------------------------------------------------
please help.
Take a look at the blog post below. I use 3 picklists in the Visualforce page that are referenced in the controller extension. This should help.
http://blog.jeffdouglas.com/2008/11/25/dependent-multilevel-selectlists/
Jeff Douglas
Informa Plc
blog.jeffdouglas.com
Thanks a lot for the help