Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't create a sharing rule #287

Open
apoyatosfinancialforce opened this issue Sep 21, 2022 · 2 comments
Open

Can't create a sharing rule #287

apoyatosfinancialforce opened this issue Sep 21, 2022 · 2 comments

Comments

@apoyatosfinancialforce
Copy link

Right now it's not possible to create a sharing rule using the MetadataService.cls class and the MetadataServiceExamples.cls provided.

In first instance with that code we get an error suggesting that SharingTerritoryRule is missing, so trying to add this new parameter to the example of createSharingRule provided in MetadataServiceExamples.cls :

testSharingRule.sharingTerritoryRules = new List<MetadataService.SharingTerritoryRule>(); MetadataService.SharingTerritoryRule sharingTerritoryRule = new MetadataService.SharingTerritoryRule(); sharingTerritoryRule.fullName = 'TestTerritory'; sharingTerritoryRule.accessLevel = 'Read'; sharingTerritoryRule.label = 'Test'; sharingTerritoryRule.sharedTo = new MetadataService.SharedTo(); sharingTerritoryRule.sharedTo.allPartnerUsers = '';

We still get an error showing that SharingTerritoryRule must contain a sharedFrom field, that is where a mistake is made on MetadataService.cls because in the actual documentation it is said that SharingTerritoryRule extends SharingOwnerRule , and that is not the case.

@apoyatosfinancialforce
Copy link
Author

apoyatosfinancialforce commented Sep 21, 2022

I thought that adding sharedFrom attribute to the SharingTerritoryRule could fix this, but this field is not present in that class:
sharingTerritoryRule.sharedFrom = new MetadataService.SharedTo(); sharingTerritoryRule.sharedFrom.allInternalUsers = '';

Also tried to add the field in 2 different ways:

  1. Trying to make SharingTerritoryRule to extend SharingOwnerRule and not SharingBaseRule, for that we have to make the SharingOwnerRule class virtual:
    public virtual class SharingOwnerRule extends SharingBaseRule {

But with this method we get an error:
sharedFrom not found in the field order.

  1. Trying to manually add sharedFrom fields to SharingTerritoryRule, and also changing expected fields:
    public MetadataService.SharedTo sharedFrom; private String[] sharedFrom_type_info = new List<String>{ 'sharedFrom', SOAP_M_URI, null, '1', '1', 'false' }; private String[] field_order_type_info = new List<String>{'fullName', 'accessLevel', 'accountSettings', 'description', 'label', 'sharedTo', 'sharedFrom'

But still got this unknown error:
Captura de Pantalla 2022-09-21 a las 13 53 38

@ingotlsc
Copy link

Wanted to bump this issue. I am experiencing the same thing myself. Salesforce support looking at the error codes I sent over to them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants