Best Practices for Extracting UserAccessRecord in Wave Analytics
|Knowledge Article Number||000233162|
|Description||You may wish to control record access in Wave Analytics based on the UserRecordAccess object. This object is peculiar and has limitations that make it difficult to interact with. The default Salesforce Dataflow structure cannot extract data from the object. The workaround below may allow your org to use this object.
The following caveats apply:
Consider the following implications if you choose to use this object:
|Resolution|| Salesforce Support cannot provide troubleshooting assistance for this workaround.
1. Create an apex class that extracts data from
SELECT RecordId, HasReadAccess, HasTransferAccess, MaxAccessLevel FROM UserRecordAccess WHERE UserId = [single ID] AND RecordId = [single ID] //or Record IN [list of IDs]
*** OR ***
SELECT Id, Name, UserRecordAccess.HasReadAccess FROM Account
2. Insert results/data into a Custom Object.
3. Use Apex Scheduler to create a Schedulable interface for the class.
4. Specify a schedule for the job to run (off-peak hours are recommended).
5. Wave dataflow runs extracting User Record Access data from the custom object and augments datasets as needed.
Sample code from Developer Forum to extract UserRecordAccess data:
List<Id> recIdLst = new List<Id>([Select ID FROM Account]); MAP<ID,UserRecordAccess> usrAcsMap = new MAP<ID,UserRecordAccess>( [SELECT RecordId, HasReadAccess FROM UserRecordAccess WHERE UserId =:UserInfo.getUserId() AND RecordId IN :recIdLst] );