You need to sign in to do that
Don't have an account?
bprakash
Batch apex code
hi,
I had something wrong with the batch apex,
global class AssetUpdateContract1 implements Database.Batchable<sObject> {
String query = 'select Id, AssetId, Key__c, Status, StartDate, EndDate, CreatedDate, PricebookEntry.Product2.Type__c, PricebookEntry.Product2.Level__c,PricebookEntry.Product2.Sharing_Content_Option__c,PricebookEntry.Product2.License_Feature__r.Name from ContractLineItem';
Public Boolean runTestMethod = false;
global AssetUpdateContract1() {
}
global AssetUpdateContract1(String q) {
query = q;
}
global database.queryLocator start(Database.BatchableContext BC) {
if(runTestMethod) {
query = query + ' LIMIT 200';
}
return database.getQueryLocator(query);
} //Close start Method
global void execute(Database.BatchableContext BC, list<ContractLineItem> ConList) {
Set<Id> assetIdSet = new Set<Id>();
Set<Id> assetIdSet1 = new Set<Id>();
Set<Id> assetIdSet2 = new Set<Id>();
Set<Id> assetIdSet3 = new Set<Id>();
Map<Id, List<ContractLineItem>> assetCLIList = new Map<Id, List<ContractLineItem>>();
Map<Id, List<ContractLineItem>> assetCLIList1 = new Map<Id, List<ContractLineItem>>();
Map<Id, List<ContractLineItem>> assetCLIList2 = new Map<Id, List<ContractLineItem>>();
Map<Id, List<ContractLineItem>> assetCLIList3 = new Map<Id, List<ContractLineItem>>();
for(ContractLineItem Con : ConList){
if(Con.AssetId != null && (Con.Status =='Active' ||Con.Status =='Inactive') && Con.PricebookEntry.Product2.License_Feature__c != null && Con.PricebookEntry.Product2.License_Feature__r.Name == 'FireEye Support') {
if(assetCLIList.get(Con.AssetId) != null) {
List<ContractLineItem> tempCLIList = (List<ContractLineItem>)assetCLIList.get(Con.AssetId);
tempCLIList.add(Con);
}
else {
List<ContractLineItem> tempCLIList = new List<ContractLineItem>();
tempCLIList.add(Con);
assetCLIList.put(Con.AssetId, tempCLIList);
}
assetIdSet.add(Con.AssetId);
}
in those Contract Line items need to sort according to get the max end date for each asset,min start date for each asset.Please take a look and i needed really urgent help from the community as iam struggling for a week but still not getting the desired result,Please help me ou of this
Thanks
Kan
any help is greatly appreciated,