Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- List<cxsrec__cxsCandidate__c> candidates = [SELECT Id, Formula_Expiry_Privacy_Agreement__c FROM cxsrec__cxsCandidate__c WHERE cxsrec__E_mail_address__c LIKE 'anontest%'];
- List<Task> taskList = new List<Task>();
- List<ConnectApi.BatchInput> batchInputs = new List<ConnectApi.BatchInput>();
- List<Attachment> attachmentList = new List<Attachment>();
- for(cxsrec__cxsCandidate__c candidate : candidates) {
- taskList.add(new Task(Subject = 'Testaufgabe soll weg', Description = 'Das sollte nicht mehr hier stehen', Status = 'Open', WhatId = candidate.Id));
- taskList.add(new Task(Subject = 'Testaufgabe soll anonymisiert werden', Description = 'Das sollte nicht mehr hier stehen', Status = 'Completed',WhatId = candidate.Id));
- Attachment att=new Attachment();
- att.Body=Blob.valueOf('Sollte weg');
- att.Name='Note_' + System.now().format('yyyy_MM_dd_hh_mm_ss') + '.txt';
- att.ParentId=candidate.Id;
- attachmentList.add(att);
- ConnectApi.FeedItemInput input = new ConnectApi.FeedItemInput();
- input.subjectId = candidate.Id;
- input.visibility = ConnectApi.FeedItemVisibilityType.AllUsers;
- ConnectApi.MessageBodyInput bodyInput = new ConnectApi.MessageBodyInput();
- bodyInput.messageSegments = new List<ConnectApi.MessageSegmentInput>();
- ConnectApi.TextSegmentInput textSegment = new ConnectApi.TextSegmentInput();
- textSegment.text = 'Test.';
- bodyInput.messageSegments.add(textSegment);
- input.body = bodyInput;
- ConnectApi.BatchInput batchInput = new ConnectApi.BatchInput(input);
- batchInputs.add(batchInput);
- }
- insert attachmentList;
- ConnectApi.ChatterFeeds.postFeedElementBatch(null, batchInputs);
- insert taskList;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement