function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
rathi007rathi007 

check box is not check

trigger CheckChatterPostsOnAccount on FeedItem (After insert) {
//Get the key prefix for the Account object via a describe call.
String oppKeyPrefix = Account.sObjectType.getDescribe().getKeyPrefix() ;
for (FeedItem f: trigger.new)
{
String parentId = f.parentId;
System.debug(oppKeyPrefix);
System.debug(parentId.startsWith(oppKeyPrefix)&& f.Body.contains('#' ));
//We compare the start of the 'parentID' field to the Account key prefix to
//restrict the trigger to act on posts made to the Account object.
if (parentId.startsWith(oppKeyPrefix)&& f.Body.contains('#' ))
{
// Account a=new Account();
Account a=[select name,test_check__c from Account where id =:parentId];
system.debug(a.test_check__c );
a.test_check__c =true;
system.debug(a.test_check__c );
update a;
}
}
}

souvik9086souvik9086

There are some places where you violated the common practices of apex.

You have used SOQL Queries and DML statements inside for loop.

Try to avoid that by querying it outside for loop and adding the account record to a account list and then update that account list outside loop.

 

if the post is helpful please throw KUDOS

Thanks

cplusplus_pleasecplusplus_please

Even if it's inside the loop.. Why is it not checked? Are you saying that Apex does not execute query commands if it's within a loop?

 

 

=============================
Developer for www.voicent.com
Voicent provides CRM, auto dialer, predictive dialer, reminder, and call center solution that is suitable for anyone in any level
Voicent strives to meet customer demands to integrate Voicent software with CRM of their choice.