Guest User

Untitled

a guest
Dec 11th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. SELECT Id, Parent.RecordTypeId FROM FeedItem WHERE Type='EmailMessageEvent' AND Visibility!='AllUsers' AND Parent.Type = 'Case' AND Parent.RecordTypeId = '01258000000cZYOAA2'
  2.  
  3. global class EmailFeeditemBatch implements Database.Batchable<sObject>, Schedulable{
  4.  
  5. global Database.QueryLocator start(Database.BatchableContext BC){
  6. RecordType rt = [SELECT ID FROM RecordType WHERE DeveloperName = 'Support' AND SobjectType = 'Case' LIMIT 1]; //PUT THIS UP
  7.  
  8. String query = 'SELECT Id, Parent.RecordTypeId FROM FeedItem WHERE Type='EmailMessageEvent' AND Visibility!='AllUsers' AND Parent.Type = 'Case' AND Parent.RecordTypeId = ''+rt.Id+''';
  9. System.debug(query);
  10. return Database.getQueryLocator(query);
  11. }
  12.  
  13.  
  14. global void execute(Database.BatchableContext BC, List<FeedItem> scope){
  15.  
  16. List <FeedItem> feedItemToUpdateList = new List<FeedItem>();
  17. for(FeedItem feedItem_i : scope){
  18. feedItem_i.Visibility = 'AllUsers';
  19. feedItemToUpdateList.add(feedItem_i);
  20. }
  21. if (feedItemToUpdateList.size()>0){
  22. update feedItemToUpdateList;
  23. }
  24. }
  25.  
  26. global void finish(Database.BatchableContext BC){
  27.  
  28. }
  29.  
  30. global void execute(SchedulableContext sc) {
  31.  
  32. database.executeBatch(new EmailFeeditemBatch(), 5);
  33. }
Add Comment
Please, Sign In to add comment