0

I'm new to Salesforce and Apex, and I'm encountering an issue with my webhook setup. I've created a site using an Apex class to receive webhooks, and it's working well. The problem arises when I try to query for records using an external ID to determine if I need to create or update the custom object.

Initially, my queries returned no results. I discovered that the custom object is not queryable, even when I use "Schema.isQueryable". I've double-checked the API name, profile permissions, and field level security, and they all seem fine. After extensive searching, I found suggestions that this might not be possible due to restrictions with the Guest User license for the site.

I'd appreciate any suggestions or advice on how to tackle this issue. If you need specific code snippets or screenshots, please let me know, and I'll gladly provide them. Thank you so much for your help!

2
  • Guest users can now only use apex code that is without sharing, so double check your code and ensure that all code you use from the site is either without sharing or (if called behind such a class) inherited sharing.
    – Phil W
    Commented May 20, 2023 at 15:48
  • @PhilW thanks so much for the help. this was going to drive me insane. I wish this was an answer so i could mark this answered. Commented May 22, 2023 at 15:15

1 Answer 1

0

Guest users can now only use apex code that is without sharing, so double check your code and ensure that all code you use from the site is either without sharing or (if called behind such a class) inherited sharing.

You'll find this in the documentation:

Any Apex code that creates and updates a record (in a single transaction) as a guest must run without sharing, also known as system mode. In such cases, when Apex code runs without sharing, the guest user should only update records they’ve just created, and no other record in Salesforce.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .