You are here:
RenewContractBatchJobQueryInterface
Returns the query that gets a list of contracts that are ready for renewal.
Type
Loosely typed
Triggered When
The first part of the RenewContractBatchJob triggers the RenewContractBatchJobQueryInterface.
Signature
Access |
Signature |
|---|---|
global |
|
Default Implementation
The DefaultContractRenewalQueryDefaultContractRenewalQuery implementation is IsAutoRenew__c = false
AND RenewalStartDate__c < today.
Other Implementations
None
Input Parameters
None
Output Parameters
query
Required
The query that the batch job will execute, for example:
'Select Id,AutoRenewObjectCreation__c,SendRenewalNotification__c from Contract
where IsAutoRenew__c = false AND RenewalStartDate__c < '+today+
' AND RenewalStartDate__c > '+lastRunDateSample Implementation
global with sharing class DefaultContractRenewalQuery implements VlocityOpenInterface
{
global Boolean invokeMethod(string methodName, Map<string, object> inputMap, Map<string, object> outMap, Map<string, object> options)
{
Boolean success = true;
try
{
if(methodName == 'getQueryString')
{
getQueryString(inputMap, outMap, options);
}
}
catch(Exception ex)
{
success = false;
throw ex;
}
return success;
}
private void getQueryString(Map<string, object> inputMap, Map<string, object> outMap, Map<string, object> options)
{
string lastRunDate = '2000-01-01';
//Get today's date
Date todaysDate = Date.today();
Integer year = todaysDate.year();
Integer month = todaysDate.month();
Integer day = todaysDate.day();
string dayString = string.valueOf(day);
string monthString = string.valueOf(month);
if(day < 10)
{
dayString = '0' + day;
}
if(month < 10)
{
monthString = '0' + month;
}
string today = year + '-' + monthString + '-' + dayString;
//Get last batch job run date
List<CpqConfigurationSetup__c> cpqSetUpList = [SELECT
Id,
Name,
SetupValue__c
FROM
CpqConfigurationSetup__c
WHERE
Name = 'ContractRenewalBatchJob'];
if(cpqSetUpList.size() != 0)
{
lastRunDate = cpqSetUpList.get(0).SetupValue__c;
}
string query = 'Select Id,AutoRenewObjectCreation__c,SendRenewalNotification__c from Contract where IsAutoRenew__c = false AND RenewalStartDate__c < ' + today + ' AND RenewalStartDate__c > ' + lastRunDate;
outMap.put('query', query);
}
}
