You need to sign in to do that
Don't have an account?
sailer
delete the specific records that meet the condition below from Chatter feed by windows batch
HI All,
I need to delete the chatter post based on some condition like
feeds which start from "(abc) and its posted by system administrator.
i wrote the batch ,but it delete all the post in the feed.
That is also particular about the feed like accountfeed
" AccountFeed[] feed = [SELECT Id FROM AccountFeed ]; Delete feed;
"
how to add the condition here .. and suppose if in the chatter i have the feed that starts with "abc" how to delete that .:)
can any one help me out Please.
Regards
Sailer
Hi Sailer,
The following where clause should help you get the feeds starting with abc:
AccountFeed[] feed = [SELECT Id FROM AccountFeed where Body like 'abc%' ]; Delete feed
Hope this helps!
Hi
If i write the query like this i wil get the error
AccountFeed[] feed = [SELECT Id FROM AccountFeed where Body like 'Test22%' ];
Delete feed;
Pl help me out.
if in the feed if i get the value with test22 i need to delete that feed is that possible.
Thanks in advance
Regards
Sailer
AccountFeed[] feed = [SELECT Id FROM AccountFeed where Body like 'Test22%' ];
AccountFeed[] feedtoDelete = new AccountFeed[]{};
for(AccountFeed f : feed)
{
String feedbody = f.Body.toString();
if(feedbody.startsWith('abc'))
feedtoDelete.add(f);
}
if(feedtoDelete.size() > 0)
delete feedtoDelete;
HI everone,
i wrote the batch below is the code but getting the error "
Error: Compile Error: Method does not exist or incorrect signature: [String].toString() at line 23 column 16
global class MyBatchable implements Database.Batchable<sObject> { private final String initialState; String query; global MyBatchable(String intialState) { this.initialState = initialState; }
global Database.QueryLocator start(Database.BatchableContext BC) { // Access initialState here return Database.getQueryLocator(query); }
global void execute(Database.BatchableContext BC, List<AccountFeed> batch) { // Access initialState here
AccountFeed[] feed = [SELECT Id FROM AccountFeed]; AccountFeed[] feedtoDelete = new AccountFeed[]{};
for(AccountFeed f : feed) { String feed2= f.Body.toString(); if(feed2.startsWith('abc')) feedtoDelete.add(f); }
if(feedtoDelete.size() > 0) delete feedtoDelete;
}
global void finish(Database.BatchableContext BC) { // Access initialState here }
}
Pl help me out ..
Regards
Sailer.
global class deleteAccountFeeds implements Database.Batchable<sObject>
{
global final String query;
global deleteAccountFeeds(String query)
{
query = 'SELECT Id, Body FROM AccountFeed';
}
global Database.QueryLocator start(Database.BatchableContext BC)
{
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext BC, List<sObject> scope)
{
List<AccountFeed> feedToDelete = new List<AccountFeed>();
for(sObject s : scope)
{
AccountFeed p =(AccountFeed)s;
if(p.Body.startsWith('abc'))
{
feedToDelete.add(p);
}
}
delete feedToDelete;
}
global void finish(Database.BatchableContext BC)
{
}
}