Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT Id, Parent.RecordTypeId FROM FeedItem WHERE Type='EmailMessageEvent' AND Visibility!='AllUsers' AND Parent.Type = 'Case' AND Parent.RecordTypeId = '01258000000cZYOAA2'
- global class EmailFeeditemBatch implements Database.Batchable<sObject>, Schedulable{
- global Database.QueryLocator start(Database.BatchableContext BC){
- RecordType rt = [SELECT ID FROM RecordType WHERE DeveloperName = 'Support' AND SobjectType = 'Case' LIMIT 1]; //PUT THIS UP
- String query = 'SELECT Id, Parent.RecordTypeId FROM FeedItem WHERE Type='EmailMessageEvent' AND Visibility!='AllUsers' AND Parent.Type = 'Case' AND Parent.RecordTypeId = ''+rt.Id+''';
- System.debug(query);
- return Database.getQueryLocator(query);
- }
- global void execute(Database.BatchableContext BC, List<FeedItem> scope){
- List <FeedItem> feedItemToUpdateList = new List<FeedItem>();
- for(FeedItem feedItem_i : scope){
- feedItem_i.Visibility = 'AllUsers';
- feedItemToUpdateList.add(feedItem_i);
- }
- if (feedItemToUpdateList.size()>0){
- update feedItemToUpdateList;
- }
- }
- global void finish(Database.BatchableContext BC){
- }
- global void execute(SchedulableContext sc) {
- database.executeBatch(new EmailFeeditemBatch(), 5);
- }
Add Comment
Please, Sign In to add comment