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

Newbie SELECT question

I;m trying to use SQL in a trigger, and it works as long as I don't use the WHERE clause. Can anyone tell me what I'm doing wrong? All I know is that it's not bringing back any records -- is it the syntax? I've checked the spelling of the fields.


Idea mainIdea = [SELECT Id, PostId__c from Idea WHERE PostId__c = :c.ParentId LIMIT 1];


PostId__c is a field I've added to Idea, and c is a FeedComment.

Ritesh AswaneyRitesh Aswaney

if the syntax was incorrect, your code wouldn't compile and you wouldnt be able to save it.

Hopefully the ParentId is not null i.e. you ought to have selected the ParentId in the FeedItem soql you may have be executing prior to this query


Above the query, put this:


system.debug('c.ParentId value: ' + c.ParentId)



Then use the Debug Logs to find out what the value is. Seems like it's something that doesn't match any Idea records.


Is this is resolved or you are still facing some issues?


I've tried the system debug line, and it seems that the parentId of the FeedComment isn't the FeedItem to which it's attached, but the Group ID (plus another three characters that aren't in the Group Id....hmmm). So I have to figure out how to identify the actual FeedItem that this comment is attached to.