You need to sign in to do that
Don't have an account?

SOQL Query in Apex Class
Please find below code is fetching the user's time off based on ownerid and user market. Some time we are getting the wrong datas like fetching the datas only based on the market.
for(Working_Days__c wd : [select Id,User__c,Start_Date__c,End_Date__c,Expired__c,Market__c,RecordTypeId,Reason__c,Time__c,
M_AM__c,M_PM__c,Tu_AM__c,Tu_PM__c,W_AM__c,W_PM__c,
Th_AM__c,Th_PM__c,F_AM__c,F_PM__c,Sat_AM__c,Sat_PM__c,
Sun_AM__c,Sun_PM__c
from Working_Days__c
where Expired__c = false and (User__c = :ownerId or Market__c = :userMarket) order by Time__c asc nulls last])
Expectation:
we are planning change the condition " where Expired__c = false and (User__c = :ownerId or (Market__c = :userMarket AND RecordTypeId= 'Company_Holdidays' "
But, we are facing problem in " RecordTypeId= 'Company_Holdidays' " , please help me how to define and excute the same.
YourName => Setup => Monitoring => Scheduled job.
Or you can dirctly type in left search box panel
All Answers
Hi,
You are not passing record type id. You are passing record type name RecordTypeId= 'Company_Holdidays' .
You have to find the recordtype id first and then make query for it.
This is the part of apex class , so i could not able to pass the value directly...
Hi Ram,
You have to fine id from Recordtype as
RecordType r= [select id from RecordType where name=:'Company_Holdidays'' and SobjectType =:'Put Object api name here'];
and now you can make a query here:
Market__c = :userMarket AND RecordTypeId=:r.id
Yes, I tried even the same. but i got error " Error: Compile Error: Schedulable class has jobs pending or in progress at line 12 column 8"
Either it is a batch or a batch is calling this class. You will have to delete all Scheduled job which are using this code. If you will not delete job you will not be able to update class or batch code.
Please advise me , where i need to delet the batch file, please find below line
In line 12: global class CyclePlanTOTSyncBatch implements Database.Batchable<sObject>
YourName => Setup => Monitoring => Scheduled job.
Or you can dirctly type in left search box panel