I want to get Account's name based on their type. How to bind types of account from visualpage to extension to get the respective account's name on page? For ex: if type is "prospect" then it should fetch all account's name having type as prospect.
You can create a controller with a method that make a soql filter by type
public with sharing class AccountBasedOnTypeController {
private String theType;
public List<Account> accountList {get; set;}
public AccountBasedOnTypeController()
{
theType = 'Prospect';
accountList = calculateAccounts(theType);
}
public List<Account> calculateAccounts(String filterByType)
{
return [Select Id, Name, Type From Account Where Type = :filterByType];
}
}
And a visualfoce page with a table showing the fields.
Thanks Garcia....But the requirement is that means I need to select type of account from picklist on visualforce page then with the help of search button I need to get Account names. Can I do it with the help of inputfield?
And a visualfoce page with a table showing the fields.
If you need more fields, just add them on the soql and in the table.
Hope this helps
Agustina
on visualforce page then with the help of search button I need to get Account names. Can I do it with the help of inputfield?
Use apex:selectList (https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_selectList.htm) tag and populate it with all Account type values. Once the end user selects one of them, use the value to make a soql like I did in the code above. The only difference is that I set a specific valye and you need a dynamic one.