0

Objects involved A, B and C.

Scenario:

I'm inserting A record which in turn inserts B Record(Happen at after insert trigger of A).

Now Lets say B trigger insert C record (Off course after insert trigger of B ).

Now I have a look up on C record to A record and able to put it to C record lookup filed by passing as a parameter (Id of A record).

The challenge I'm facing here is at C trigger I have a map where I wish to build <Key = Id of A record and Value as A record.> => Here I'm querying for A record all required fields, But query returns null !.

Can someone please explain am I missing something in Order of Execution ? (A record is not yet committed to data base but since it's in after context Id is generated and Can't I query it until record is committed to database ?)

Thanks in advance.

Update:

This was failing because run as is being doing as guest user.

5
  • 5
    You should be able to query the values; if not, you're probably doing something wrong. However, we'd have to see some code in order to figure out what's going on. I realize the whole thing might be too complicated, but if you could include just the relevant code, that might help. – sfdcfox Jul 23 '20 at 19:45
  • Hi sfdxfox thanks for confirmation, I will try to figure it out, just that wanted to confirm the possibility. It works fine in actual flow meaning when I insert a record from UI / Data loader ,but when inserting record A in the test class this scenario is failing at the point C trigger where the query for A is. fyi I was expecting you to confirm this first here :) thanks @sfdxfox as always. – vkm Jul 23 '20 at 19:49
  • @sfdxfox got the root cause this is cause the salesforce update : Guest User: New Guest User Access Setting and Removed Retired Permissions. (I'm running as runas guest user then it fails and if as sys admin user it works well) – vkm Jul 24 '20 at 9:42
  • 1
    That makes sense. This is the sort of thing that would have been useful to include in the question. I know it's sometimes hard to figure out what's relevant in a case like this, but I'd recommend mentioning the context (Communities, etc), as it can really help. – sfdcfox Jul 24 '20 at 13:15
  • @sfdcfox thanks you, sure I will keep questions neat and will do proper tagging. – vkm Jul 24 '20 at 13:58
1

Need to update the permissions:

Salesforce Spring ’20 Release:

Guest User: New Guest User Access Setting and Removed Retired Permissions

Not the answer you're looking for? Browse other questions tagged or ask your own question.