function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Raghu Ch 2Raghu Ch 2 

USING THIS_WEEK Filter in custom setting

Hi, I am trying to use THIS_WEEK date filter in my custom setting and trying to refrence it in my code. I am getting the below error:
System.TypeException: Invalid date: THIS_WEEK

Code snippet below:

PayCycleInformationWrapper payCycleInfoWrap=new PayCycleInformationWrapper(); List<cve__PaymentScheduleItem__c> psItemList=new List<cve__PaymentScheduleItem__c>(); Map<string,cve__PaymentScheduleItem__c> payFreqPSItemMap=new Map<string,cve__PaymentScheduleItem__c>(); WTW_Report_Parameters__c wtwReportParams = WTW_Report_Parameters__c.getInstance(UserInfo.getProfileId()); String payableTime=wtwReportParams.Payable__c;  // place where i am storing THIS_WEEK as filter
Date payableDate=Date.valueOf(payableTime);
String payFrequency=wtwReportParams.Pay_Frequency__c; set<string> payFrequencySet=new set<string>(); payFrequencySet.add(payFrequency);

psItemList=[ Id FROM cve__PaymentScheduleItem__c where cve__PaymentSchedule__r.Name Like '%OnCycle%' and cve__payable__c=:payableDate and cve__paymentschedule__r.Name ];
THIS_WEEK should be passed as a string so remove below line and replace payableDate with payableTime in the query,

Date payableDate=Date.valueOf(payableTime);