CBS Rule Share not created if insertion of custom object and WorkOrder are performed in the same transaction using Apex
Last updated 2020-07-08 ·Reference W-7744382 ·Reported By 0 users
If criteria-based sharing (CBS) rules exists on a custom object, WorkOrder and Case objects, the criteria-based sharing rule share is not created when the custom object and the work order are created in the same transaction.
1) Create a custom object called "Street".
2) On Street, create a custom field called "Country".
3) Enable Field Service
4) In Sharing Settings, make sure the sharing settings are Private for both Street and Work Order.
5) On Work Order, create a record type with label "Colombia".
6) Create criteria-based sharing rules for both Case, Street, and Work Order and Street
6.a) For Case, sharing rule would be: Case: Status EQUALS New
6.b) For Street, sharing rule would be: Street: (Country EQUALS COLOMBIA) OR (Street: Country EQUALS Colombia)
6.c) For Work Order, sharing rule would be: Work Order: Record Type EQUALS Colombia.
7) Execute the below anonymous Apex code in Developer Console:
Street__c st = new Street__c(Country__c = 'COLOMBIA');
Case c = new Case(Subject = 'Test ' + System.now());
WorkOrder wo = new WorkOrder(CaseId = c.Id, RecordTypeId = '0125w000000LhcR'); // 012... is the ID of the "Colombia" record type
Actual result: A SOQL query on Street__Share filtering on the new Street record returns a single row where RowCause is Owner.
Expected result: A SOQL query on Street__Share filtering on the new Street record should also return a row where RowCause is Rule, as this will open up access as per the criteria-based sharing rule on this entity.
Open the new Street record, edit and save it without changes. Alternatively, consider inserting the work order in a separate transaction.
Reported By (0)
Is it Fixed?
Any unreleased services, features, statuses, or dates referenced in this or other public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make their purchase decisions based upon features that are currently available.