You need to sign in to do that
Don't have an account?
Shephali Swarnkar
working with list
Hi all,
I have a list where i am passing the value of Sobject(id and name).but now i need to fetch the Alias for the user which user's name is being selected from the list.how to get this???
public class report
{
public list<selectoption> options{get;set;}
public User b{get;set;}
public Boolean isSelected{get;set;}
public Id SelectedOwnerId{get;set;}
public report()
{
getoptions();
}
public list<selectoption> getoptions()
{
options = new list<selectoption>();
for(user b : [Select Id, Name, Alias from User where IsActive = true Order by Name])
{
options.add(new selectoption(b.Id,b.Name));
}
return options;
}
I have a list where i am passing the value of Sobject(id and name).but now i need to fetch the Alias for the user which user's name is being selected from the list.how to get this???
public class report
{
public list<selectoption> options{get;set;}
public User b{get;set;}
public Boolean isSelected{get;set;}
public Id SelectedOwnerId{get;set;}
public report()
{
getoptions();
}
public list<selectoption> getoptions()
{
options = new list<selectoption>();
for(user b : [Select Id, Name, Alias from User where IsActive = true Order by Name])
{
options.add(new selectoption(b.Id,b.Name));
}
return options;
}
Check the below code it will work fine. if you need any clarification contact me!!!!
<apex:page controller="report">
<apex:form id="frm">
<apex:selectList size="1" value="{!SelectedOwnerId}">
<apex:selectOptions value="{!options}"/>
<apex:actionSupport event="onchange" reRender="frm" action="{!sel}"/>
</apex:selectList>
<apex:outputText >{!Name}</apex:outputText>
</apex:form>
</apex:page>
public class report
{
public list<selectoption> options;
public User b{get;set;}
public Boolean isSelected{get;set;}
public Id SelectedOwnerId{get;set;}
public String Name{get;set;}
public Map<id,User> userMap;
public report()
{
userMap=new Map<id,User>([Select Id, Name, Alias from User where IsActive = true Order by Name]);
}
public Void sel(){
Name=userMap.get(SelectedOwnerId).Name;
}
public list<selectoption> getoptions()
{
options = new list<selectoption>();
for(user b : userMap.values())
{
options.add(new selectoption(b.Id,b.Name));
}
return options;
}
}
All Answers
Check the below code it will work fine. if you need any clarification contact me!!!!
<apex:page controller="report">
<apex:form id="frm">
<apex:selectList size="1" value="{!SelectedOwnerId}">
<apex:selectOptions value="{!options}"/>
<apex:actionSupport event="onchange" reRender="frm" action="{!sel}"/>
</apex:selectList>
<apex:outputText >{!Name}</apex:outputText>
</apex:form>
</apex:page>
public class report
{
public list<selectoption> options;
public User b{get;set;}
public Boolean isSelected{get;set;}
public Id SelectedOwnerId{get;set;}
public String Name{get;set;}
public Map<id,User> userMap;
public report()
{
userMap=new Map<id,User>([Select Id, Name, Alias from User where IsActive = true Order by Name]);
}
public Void sel(){
Name=userMap.get(SelectedOwnerId).Name;
}
public list<selectoption> getoptions()
{
options = new list<selectoption>();
for(user b : userMap.values())
{
options.add(new selectoption(b.Id,b.Name));
}
return options;
}
}
Hi Venkat!!!
Can we count how many checked checkboxes we have in a field with checkbox datatype.if yes how?query for same.!!
Hi Shephali Swarnkar,
Please refer the below code to count no.of checked chekbox, the bolded code is used to get checked checkbox condition. If you have any queries post here.
Code:
select count(id) from sObject(Ex: Account) group by Checkbox Api Field(Ex: Active_Account__c) having Checkbox Api Field(Ex: Active_Account__c)=true