0

I am trying to deploy some Apex-based sharing. Everything works fine in sandbox and code is 100% covered. I have a set of contacts (with a related User field) and a set of Project Task records (a Private object). Both the Contact records and the Project Task records have a matching Department picklist. I have triggers on both objects executing @future methods to do the following:

  • Share the Project Task with the related users of all Contact records with a matching department after Project Task insert (or update on Department change) if they haven't been shared the record already
    • Share all Project Tasks with the related user when a new Contact is inserted that match that Contact's department.

Everything works perfectly in sandbox, but I get this error upon deployment for both methods:

sObject type 'pse__Project_Task__Share' is not supported. If you are attempting to use a custom object, be sure to append the '__c' after the entity name. Please reference your WSDL or the describe call for the appropriate names.

I'm getting the error specifically when I first query the Share object to see what records exist already:

for(pse__Project_Task__Share pts : [SELECT ParentId, UserOrGroupId
                                            FROM pse__Project_Task__Share
                                            WHERE ParentId IN : taskMap.keyset()])
4
  • Check if "pse__Project_Task" object exist in production? or you are deploying object and this code component altogether? Mar 15, 2017 at 15:41
  • The object exists in production (pse__Project_Task__c). Oh, you know what you made me think of... I think I didn't include the Sharing Reason in the change set! That might be why the Share object doesn't exist. Checking.
    – Andy H
    Mar 15, 2017 at 15:42
  • Is sharing enabled in production for that object? In production?
    – kurunve
    Mar 15, 2017 at 15:43
  • I had not yet made the object private in production. OWD was still public read/write. As soon as I made it private it worked fine. Lesson learned. Thank you kurunve and Santanu Boral for getting me thinking in the right direction.
    – Andy H
    Mar 15, 2017 at 15:49

1 Answer 1

2

So if it helps anybody else this was because I still had the OWD for the object as Public Read/Write in production, where I had made it Private in sandbox. Apparently the related __Share object doesn't exist if the object in question has never been private. As soon as I made the object private in production it worked fine. Thanks.

1
  • 2
    If you've solved your own issue, you should accept your own answer, so that the question falls out of the "Unanswered Questions" list. Mar 15, 2017 at 15:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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