3

Begging your understanding,

My app creates 3 FolderShare objects, a ReportFolder object, sets the FolderShare objects to the ReportFolder obj, finally creating the ReportFolder object, to wit:

theApp.sfConnectionSandboxMetadata = Utilities.connectToSalesforceMetadata( "conv3");

aFolderShareObjA = createFolderShareObj( "00Ge0000000LAKo", FolderShareAccessLevel.EditAllContents, FolderSharedToType.Group);
aFolderShareObjB = createFolderShareObj( "00Ge0000000LAKo", FolderShareAccessLevel.EditAllContents, FolderSharedToType.Group);
aFolderShareObjC = createFolderShareObj( "00Ge0000000LAKo", FolderShareAccessLevel.EditAllContents, FolderSharedToType.Group);

folderShare_arry = new com.sforce.soap.metadata.FolderShare[3];
folderShare_arry[0] = aFolderShareObjA;
folderShare_arry[1] = aFolderShareObjB;
folderShare_arry[2] = aFolderShareObjC;

aRepFolderObj = createReportFolderObj("RameshOwesMeLunch","RameshOwesMeATurkeySwiss",FolderAccessTypes.Public, folderShare_arry);

metadataObj_arry = new Metadata[1];
metadataObj_arry[0] =  aRepFolderObj;   

//subtlty - even though Folder is a concrete class,
//          create() wants more-complete concrete class like ReportFolder
//subtlty - had to go up from 24 to 28 on authEndPoint
AsyncResult[] ar_arry = theApp.sfConnectionSandboxMetadata.create( metadataObj_arry);

The app runs and completes w/o error and we do see the report folder in Salesforce BUT not the folder shares. Must I create the FolderShare objects in Salesforce first? And if so how are they created and how does one bind them to the ReportFolder object?

TIA,

Still-learning Steve

2

The problem is that not everything in the Metadata API is accessible via the CRUD calls. You need to use the file-based deploy() function. There's sample code to show how this is done, passing in a zip file containing the metadata.

Basically, you'll need a package.xml in the root of the zip, with content like:

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>FolderName1</members>
        <name>Folder</name>
    </types>
    <types>
        <members>FolderName2</members>
        <name>Folder</name>
    </types>
    <version>30.0</version>
</Package>

Then, in reports and/or dashboards directories in the zip, you'll have an XML file per FolderShare with names of the form FolderName1-meta.xml, and content like

<?xml version="1.0" encoding="UTF-8"?>
<ReportFolder xmlns="http://soap.sforce.com/2006/04/metadata">
  <folderShares>
       <accessLevel>View</accessLevel>
        <sharedTo>R1</sharedTo>
        <sharedToType>Role</sharedToType>
    </folderShares>
</ReportFolder>

See the FolderShare docs for more detail on the element values.

  • I don't think 'Folder' is a valid metadata type in this context. It comes down with Ant when you reference the folder as a Report, Dashboard, Template, or Document type. – Andy Ognenoff Oct 7 '15 at 18:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.