SHARE
TWEET

Untitled

a guest Apr 25th, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. List<cxsrec__cxsCandidate__c> candidates = [SELECT Id, Formula_Expiry_Privacy_Agreement__c FROM cxsrec__cxsCandidate__c WHERE cxsrec__E_mail_address__c LIKE 'anontest%'];
  2.  
  3. List<Task> taskList = new List<Task>();
  4. List<ConnectApi.BatchInput> batchInputs = new List<ConnectApi.BatchInput>();
  5. List<Attachment> attachmentList = new List<Attachment>();
  6.  
  7. for(cxsrec__cxsCandidate__c candidate : candidates) {
  8.     taskList.add(new Task(Subject = 'Testaufgabe soll weg', Description = 'Das sollte nicht mehr hier stehen', Status = 'Open', WhatId = candidate.Id));
  9.     taskList.add(new Task(Subject = 'Testaufgabe soll anonymisiert werden', Description = 'Das sollte nicht mehr hier stehen', Status = 'Completed',WhatId = candidate.Id));
  10.  
  11.     Attachment att=new Attachment();
  12.     att.Body=Blob.valueOf('Sollte weg');
  13.     att.Name='Note_' + System.now().format('yyyy_MM_dd_hh_mm_ss') + '.txt';
  14.     att.ParentId=candidate.Id;
  15.     attachmentList.add(att);
  16.  
  17.     ConnectApi.FeedItemInput input = new ConnectApi.FeedItemInput();
  18.     input.subjectId = candidate.Id;
  19.     input.visibility = ConnectApi.FeedItemVisibilityType.AllUsers;
  20.  
  21.     ConnectApi.MessageBodyInput bodyInput = new ConnectApi.MessageBodyInput();
  22.     bodyInput.messageSegments = new List<ConnectApi.MessageSegmentInput>();
  23.  
  24.     ConnectApi.TextSegmentInput textSegment = new ConnectApi.TextSegmentInput();
  25.     textSegment.text = 'Test.';
  26.  
  27.     bodyInput.messageSegments.add(textSegment);
  28.     input.body = bodyInput;
  29.  
  30.     ConnectApi.BatchInput batchInput = new ConnectApi.BatchInput(input);
  31.     batchInputs.add(batchInput);
  32. }
  33.  
  34. insert attachmentList;
  35.  
  36. ConnectApi.ChatterFeeds.postFeedElementBatch(null, batchInputs);
  37.  
  38. insert taskList;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top