You need to sign in to do that
Don't have an account?
akash_dev__c
Unknown property 'Claim_Request__cStandardController.entitlements'
Hello,
I am trying to create a visualforce page listing all the etitlements based on the userId. I have created a global class and using its function in a different class and when I am trying to show the data on the vf page it is showing me the error.
Here is my code:
VF page
<apex:page standardcontroller="Claim_Request__c" extensions="EntitlementData" >
<html>
<head>
</head>
<body>
<apex:pageBlock title="Entitlement details of the employee">
<apex:pageBlockSection columns="1">
<apex:form >
<table>
<tr>
<th>Entitlement Type</th>
<th>Entitlement Amount</th>
<th>Entitlement Applicability</th>
</tr>
<apex:repeat value="{!entitlements}" var="entitle">
<apex:repeat value="{!entitlements[entitle]}" var="map">
<tr>
<td><apex:outputfield value="{!map.Entitlement_Type__c}" /></td>
<td><apex:outputfield value="{!map.Entitlement_Amount__c}"/></td>
<td><apex:outputfield value="{!map.Applicability__c}"/></td>
</tr>
</apex:repeat>
</apex:repeat>
</table>
<br/>
</apex:form>
</apex:pageBlockSection>
</apex:pageBlock>
</body>
</html>
</apex:page>
Controller
public class EntitlementData
{
Map<Id, Object > entitlements {get;set;}
public user usr;
public EntitlementData(ApexPages.StandardController controller )
{
List <Id> lst = new list<Id>();
TESTQurty bg1 = new TESTQurty();
//query to take out the current user department information
user usr = [select id from user where id =: Userinfo.getUserId()];
lst.add(usr.Id);
entitlements = bg1.getEmployeeEntitlements(lst);
}
}
Global Class
public class TESTQurty {
// Global Enums
public enum APPLICABILITY {MONTHLY, ANNUALLY}
public enum CATEGORY {ORGANIZATIONAL, DEPARTMENTAL}
// Global Constants
public final String ENTL_DPT_REC_TYPE = 'Department Entitlement';
public final String ENTL_GBL_REC_TYPE = 'Global Entitlement';
public User usr;
// Global data structures
// To Store Entitlement Information
public class Entitlements {
Decimal Amount {get;set;}
String Type {get;set;} // Entitlement Types e.g. Phone, Broadband etc.
APPLICABILITY Applicability {get;set;}
CATEGORY Category {get;set;}
public Entitlements(Decimal Amt, String EType, APPLICABILITY apl, CATEGORY cat)
{
Amount = Amt;
Type=EType;
Applicability=apl;
Category=cat;
}
}
// To Store Claimed Data
public class ClaimedInfo {
Decimal Amount {get;set;}
String Type {get;set;} // Entitlement Types e.g. Phone, Broadband etc.
String Month {get;set;}
String Year {get;set;}
public ClaimedInfo(Decimal amt, String cType, String mon, string yr)
{
amount = amt;
Type = cType;
month = mon;
year= yr;
}
}
// Utility method to get the list of all entitlements
// applicable to the given list of employee ids
public Map<Id, List<Entitlements>> getEmployeeEntitlements(List<Id> EmployeeIds){
// Local variables
Map<Id, List<Entitlements>> mapEntilementsByEmpIds = new Map<Id, List<Entitlements>>();
Map<Id, List<Entitlements>> mapEntilementsByDepts = new Map<Id, List<Entitlements>>();
List<Entitlement__c> lstEntitlementsByEmp = new List<Entitlement__c>();
List<Entitlements> lsEntitlementGlobal = new List<Entitlements>();
// Get list of departments for the given list of employees
//Set<Id> lstDepartments = new Set<Id>();
Map<Id,Id> mapDeptByEmp = new Map<Id, Id>();
// Query Employee and get Department details
for(Employee__c emps: [SELECT Id,Department_Number__c from Employee__c where Id =: EmployeeIds]){
// Check if exist in the set if not then add
if(!mapDeptByEmp.containsKey(emps.id))
mapDeptByEmp.put(emps.id, emps.Department_Number__c);
}// End of for
System.debug('Emp By Dept : ' + mapDeptByEmp);
// Query Entitlements Object to get list of all entitlements
for(Entitlement__c entl : [SELECT Entitlement_Type__c,
Entitlement_Amount__c,
Applicability__c,
RecordType.Name,
Department_Number__c
FROM Entitlement__c
WHERE
(Department_Number__c = : mapDeptByEmp.values()
AND RecordType.Name =: ENTL_DPT_REC_TYPE)
OR RecordType.Name =: ENTL_GBL_REC_TYPE]){
// Check if this is the record is global or departmental
if(entl.RecordType.Name == ENTL_GBL_REC_TYPE){
lsEntitlementGlobal.add(new Entitlements (entl.Entitlement_Amount__c,
entl.Entitlement_Type__c,
(entl.Applicability__c=='Monthly')?APPLICABILITY.MONTHLY:APPLICABILITY.ANNUALLY,
CATEGORY.ORGANIZATIONAL
));
} else if(entl.RecordTYpe.Name == ENTL_DPT_REC_TYPE ) {
// Check if employee exists in the map
if (!mapEntilementsByDepts.containsKey(entl.Department_Number__c) ){
List<Entitlements> lstEntitlement = new List<Entitlements>();
lstEntitlement.add(new Entitlements(entl.Entitlement_Amount__c,
entl.Entitlement_Type__c,
(entl.Applicability__c=='Monthly')?APPLICABILITY.MONTHLY:APPLICABILITY.ANNUALLY,
CATEGORY.DEPARTMENTAL));
mapEntilementsByDepts.put(entl.Department_Number__c, lstEntitlement);
} else {
mapEntilementsByDepts.get(entl.Department_Number__c).add(new Entitlements(entl.Entitlement_Amount__c,
entl.Entitlement_Type__c,
(entl.Applicability__c=='Monthly')?APPLICABILITY.MONTHLY:APPLICABILITY.ANNUALLY,
CATEGORY.DEPARTMENTAL));
} /// End of Check if employee exists in the map
} // End of else if
} // End of for
system.debug(lsEntitlementGlobal);
system.debug(mapEntilementsByDepts);
// Populate the final out put map based on employee
for(Id empId:EmployeeIds ){
// Add departmental entitlements for the employee
mapEntilementsByEmpIds.put(empId, mapEntilementsByDepts.get(mapDeptByEmp.get(empId)));
// Add global list applicable for the employee
mapEntilementsByEmpIds.get(empId).addAll(lsEntitlementGlobal);
}// End of for
return mapEntilementsByEmpIds;
} // End of getEmployeeEntitlements
Thanks in Advance
I am trying to create a visualforce page listing all the etitlements based on the userId. I have created a global class and using its function in a different class and when I am trying to show the data on the vf page it is showing me the error.
Here is my code:
VF page
<apex:page standardcontroller="Claim_Request__c" extensions="EntitlementData" >
<html>
<head>
</head>
<body>
<apex:pageBlock title="Entitlement details of the employee">
<apex:pageBlockSection columns="1">
<apex:form >
<table>
<tr>
<th>Entitlement Type</th>
<th>Entitlement Amount</th>
<th>Entitlement Applicability</th>
</tr>
<apex:repeat value="{!entitlements}" var="entitle">
<apex:repeat value="{!entitlements[entitle]}" var="map">
<tr>
<td><apex:outputfield value="{!map.Entitlement_Type__c}" /></td>
<td><apex:outputfield value="{!map.Entitlement_Amount__c}"/></td>
<td><apex:outputfield value="{!map.Applicability__c}"/></td>
</tr>
</apex:repeat>
</apex:repeat>
</table>
<br/>
</apex:form>
</apex:pageBlockSection>
</apex:pageBlock>
</body>
</html>
</apex:page>
Controller
public class EntitlementData
{
Map<Id, Object > entitlements {get;set;}
public user usr;
public EntitlementData(ApexPages.StandardController controller )
{
List <Id> lst = new list<Id>();
TESTQurty bg1 = new TESTQurty();
//query to take out the current user department information
user usr = [select id from user where id =: Userinfo.getUserId()];
lst.add(usr.Id);
entitlements = bg1.getEmployeeEntitlements(lst);
}
}
Global Class
public class TESTQurty {
// Global Enums
public enum APPLICABILITY {MONTHLY, ANNUALLY}
public enum CATEGORY {ORGANIZATIONAL, DEPARTMENTAL}
// Global Constants
public final String ENTL_DPT_REC_TYPE = 'Department Entitlement';
public final String ENTL_GBL_REC_TYPE = 'Global Entitlement';
public User usr;
// Global data structures
// To Store Entitlement Information
public class Entitlements {
Decimal Amount {get;set;}
String Type {get;set;} // Entitlement Types e.g. Phone, Broadband etc.
APPLICABILITY Applicability {get;set;}
CATEGORY Category {get;set;}
public Entitlements(Decimal Amt, String EType, APPLICABILITY apl, CATEGORY cat)
{
Amount = Amt;
Type=EType;
Applicability=apl;
Category=cat;
}
}
// To Store Claimed Data
public class ClaimedInfo {
Decimal Amount {get;set;}
String Type {get;set;} // Entitlement Types e.g. Phone, Broadband etc.
String Month {get;set;}
String Year {get;set;}
public ClaimedInfo(Decimal amt, String cType, String mon, string yr)
{
amount = amt;
Type = cType;
month = mon;
year= yr;
}
}
// Utility method to get the list of all entitlements
// applicable to the given list of employee ids
public Map<Id, List<Entitlements>> getEmployeeEntitlements(List<Id> EmployeeIds){
// Local variables
Map<Id, List<Entitlements>> mapEntilementsByEmpIds = new Map<Id, List<Entitlements>>();
Map<Id, List<Entitlements>> mapEntilementsByDepts = new Map<Id, List<Entitlements>>();
List<Entitlement__c> lstEntitlementsByEmp = new List<Entitlement__c>();
List<Entitlements> lsEntitlementGlobal = new List<Entitlements>();
// Get list of departments for the given list of employees
//Set<Id> lstDepartments = new Set<Id>();
Map<Id,Id> mapDeptByEmp = new Map<Id, Id>();
// Query Employee and get Department details
for(Employee__c emps: [SELECT Id,Department_Number__c from Employee__c where Id =: EmployeeIds]){
// Check if exist in the set if not then add
if(!mapDeptByEmp.containsKey(emps.id))
mapDeptByEmp.put(emps.id, emps.Department_Number__c);
}// End of for
System.debug('Emp By Dept : ' + mapDeptByEmp);
// Query Entitlements Object to get list of all entitlements
for(Entitlement__c entl : [SELECT Entitlement_Type__c,
Entitlement_Amount__c,
Applicability__c,
RecordType.Name,
Department_Number__c
FROM Entitlement__c
WHERE
(Department_Number__c = : mapDeptByEmp.values()
AND RecordType.Name =: ENTL_DPT_REC_TYPE)
OR RecordType.Name =: ENTL_GBL_REC_TYPE]){
// Check if this is the record is global or departmental
if(entl.RecordType.Name == ENTL_GBL_REC_TYPE){
lsEntitlementGlobal.add(new Entitlements (entl.Entitlement_Amount__c,
entl.Entitlement_Type__c,
(entl.Applicability__c=='Monthly')?APPLICABILITY.MONTHLY:APPLICABILITY.ANNUALLY,
CATEGORY.ORGANIZATIONAL
));
} else if(entl.RecordTYpe.Name == ENTL_DPT_REC_TYPE ) {
// Check if employee exists in the map
if (!mapEntilementsByDepts.containsKey(entl.Department_Number__c) ){
List<Entitlements> lstEntitlement = new List<Entitlements>();
lstEntitlement.add(new Entitlements(entl.Entitlement_Amount__c,
entl.Entitlement_Type__c,
(entl.Applicability__c=='Monthly')?APPLICABILITY.MONTHLY:APPLICABILITY.ANNUALLY,
CATEGORY.DEPARTMENTAL));
mapEntilementsByDepts.put(entl.Department_Number__c, lstEntitlement);
} else {
mapEntilementsByDepts.get(entl.Department_Number__c).add(new Entitlements(entl.Entitlement_Amount__c,
entl.Entitlement_Type__c,
(entl.Applicability__c=='Monthly')?APPLICABILITY.MONTHLY:APPLICABILITY.ANNUALLY,
CATEGORY.DEPARTMENTAL));
} /// End of Check if employee exists in the map
} // End of else if
} // End of for
system.debug(lsEntitlementGlobal);
system.debug(mapEntilementsByDepts);
// Populate the final out put map based on employee
for(Id empId:EmployeeIds ){
// Add departmental entitlements for the employee
mapEntilementsByEmpIds.put(empId, mapEntilementsByDepts.get(mapDeptByEmp.get(empId)));
// Add global list applicable for the employee
mapEntilementsByEmpIds.get(empId).addAll(lsEntitlementGlobal);
}// End of for
return mapEntilementsByEmpIds;
} // End of getEmployeeEntitlements
Thanks in Advance
Hi Akash,
You need to defined "entitlements" as a public property with public getter/setter to access on a VF page.
Try following for your Controller :
Can you please Let me know if it helps or not!!!
Thanks...
I have figured out the error and yes that point was missing, I was trying to call a private constructor and it is working fine with few changes.
Thanks a lot for your help.
Regards,
Akash