Salesforce Fact #859 | NetworkId error in ContentVersion record in test class
Have you encountered the error in test class: You do not have the level of access to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary: [NetworkId]
This error is encountered while trying to insert a ContentVersion record. The insert fails because the NetworkId field is not set.
To resolve this, query the NetworkId from the network Sobject using the below SOQL and set the same in the ContentVersion record before insert:
Id networkId = [SELECT Id FROM Network LIMIT 1].Id;
Comments
Post a Comment