• Ram_Sfdc
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
Hi,

I have a visualforce page, through which I am creating a Parent and child record (master-detail relationship). Once the child is created, based on some criteria the child record updates the parent. 

In afterInsert of the child object, I have a SOQL query on Parent object and it returns 0 records.
Following is the code that I am using:

Set<Id> setParentIds = new Set<Id>();

for(){
setParentIds.add(child.Parent__c)
}
System.debug(setParentIds); - Works fine and displays Ids of parent Object

List<parent__c> = [Select Id, field__c From parent Where Id IN:setParentIds] - This will get 0 records. 

This is totally weird, I am getting Ids in 'setParentIds' Set and when I Query why would the Query show 0 records? Any thoughts! What am I missing here!