5

I am searching for a way to automate a time-consuming task for an administrator on my team: subscribing numerous users to reports ("Schedule Future Runs", Salesforce Classic). The need to for each user to receive the report with him or herself as the running user.

I understand that the Classic Schedule Future Runs functionality is represented under the hood as CronTrigger and CronJobDetail records, which cannot be created programmatically. Is there any way to create these subscriptions in another fashion? The Reports Apex namespace does not appear to offer this functionality.

I've also looked into creating Lightning report subscriptions using the Analytics API. However, that API appears to only create subscriptions for the logged-in user, and the API returns an error if a subscription already exists for the logged-in user. This makes it impossible to subscribe other users individually using the API.

1 Answer 1

2

After some time, another question by Martin Borthiry inspired me to return to this problem.

As elaborated in this answer, a scripted, off-platform solution using a Python script to call the Analytics API is able to achieve this objective by using JWT as the authentication solution.

This permits the script to log in as arbitrary users within having access to their individual credentials. By establishing that running user context, we can create subscriptions on the users' behalf to reports that run as themselves. This is suitable for one-off needs such as the situation mentioned above, as the setup needs are minimal (Connected App) and the workflow could in theory be executed with only standard tools like Salesforce DX and curl.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .