You need to sign in to do that
Don't have an account?
sfdc G 9
Below class is batch apex i have stuck on this error ? can any one can help me .
Hi all,
global class batchprocessdesc implements Database.Batchable<sObject>
{
global Database.QueryLocator start(Database.BatchableContext BC)
{
String query = 'select id from Account';
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext BC, List<Account> accounts)
{
list<Entitlement> ents = [select AccountId, id, Product_Family__c, EndDate from Entitlement where AccountId IN :accounts ORDER BY AccountId,Product_Family__c,EndDate DESC];
//Map<Id, Entitlement> pfmap= new Map<Id, Entitlement>(ents);
map<Product_Family__c,EndDate> PFMAP = new map<Product_Family__c,EndDate>(ents); // Error: Compile Error: Invalid type: EndDate at line 15 column 74
for (Entitlement objent: ents)
{
pfmap.put('Product_Family__c','EndDate');
}
}
global void finish(Database.BatchableContext BC)
{
}
}
global class batchprocessdesc implements Database.Batchable<sObject>
{
global Database.QueryLocator start(Database.BatchableContext BC)
{
String query = 'select id from Account';
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext BC, List<Account> accounts)
{
list<Entitlement> ents = [select AccountId, id, Product_Family__c, EndDate from Entitlement where AccountId IN :accounts ORDER BY AccountId,Product_Family__c,EndDate DESC];
//Map<Id, Entitlement> pfmap= new Map<Id, Entitlement>(ents);
map<Product_Family__c,EndDate> PFMAP = new map<Product_Family__c,EndDate>(ents); // Error: Compile Error: Invalid type: EndDate at line 15 column 74
for (Entitlement objent: ents)
{
pfmap.put('Product_Family__c','EndDate');
}
}
global void finish(Database.BatchableContext BC)
{
}
}
In Apex you not have "EndDate" data type, maybe you want to use Date or DateTime type.
Thanks,
Alex
There is type as "End Date" that is why it raise an error.
So should use below code :
Note :
I thing you are little bit confused from this syntax :
Map<Id, Entitlement> pfmap= new Map<Id, Entitlement>(ents);
in Map creation time if we pass list as argument then it can only be ID and Object Type. We can't use any other field as value.
map<Product_Family__c,EndDate> PFMAP = new map<Product_Family__c,EndDate>(ents).Thanks.
Let us know if this will help you
Thanks
Amit Chaudhary
I tried this but its throwing error,
thanks , Deep