function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
kurtz_wolfgangkurtz_wolfgang 

sharing Report folder dynamically

Hello All,

 

We have around 700+ report folders and we need to share reports from these folders with different set of users based on various conditions and requests. What would satisfy this requirement is to have a public group to which all these report folders are shared and then add/remove members to the group as and when needed. The problem is how do we dynamically add a group to a report folder so that it appears under "Shared to" when you click edit report folder?

 

Any suggestion would be appreciated.

 

Thanks & Regards,

kb.

jhurstjhurst

KB,

 

You can do this through the MetadataAPI.  Essentially, you you would have to download the metadata for all of the report folders, edit them to have the groups you want, and then update all of the folders.  This can be done through the Force.com IDE.

 

For example, I have a folder ("Test Folder") which is currently shared to a Role in my company ("CEO").  I also have a group created called "Test Group".  If I download the Metadata for the folder, I see the XML is:

 

<?xml version="1.0" encoding="UTF-8"?>
<ReportFolder xmlns="http://soap.sforce.com/2006/04/metadata">
    <accessType>Shared</accessType>
    <name>Test Folder</name>
    <publicFolderAccess>ReadWrite</publicFolderAccess>
    <sharedTo>
        <roles>CFO</roles>
    </sharedTo>
</ReportFolder>

  

 Now, if I want to add the "Test Group" I would change the file to be:

 

<?xml version="1.0" encoding="UTF-8"?>
<ReportFolder xmlns="http://soap.sforce.com/2006/04/metadata">
    <accessType>Shared</accessType>
    <name>Test Folder</name>
    <publicFolderAccess>ReadWrite</publicFolderAccess>
    <sharedTo>
        <groups>Test Group</groups>
        <roles>CFO</roles>
    </sharedTo>
</ReportFolder>

Then, if I save the changes to the server, the folder will be shared to the "Test Group".

 

You can find out more on the Metatdata API in the docs - http://www.salesforce.com/us/developer/docs/api_meta/index.htm

 

Hope this helps.

Jay