1

I want to create an unmanaged package using API call, is it possible? Is yes, please suggest the approach.

Our expectation is to create a unmanaged package in a salesforce org and add the metadata which is already available on the same org without modifying anything on the actual metadata. Finally we wanted to read the package content to identify the additional dependency components that were added on the package.

1

Yes, you can create unmanaged packages. Simply include the fullName attribute during a normal metadata API deployment.

Start with a normal package.xml, but specify a package:

<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <name>Package</name>
        <members>DemoPackage</members>
    </types>
    <apiVersion>44.0</apiVersion>
</Package>

In a folder by the same name as members, specify another package.xml:

<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <fullName>DemoPackage</fullName>
    <version>44.0</version>
</Package>

This sub-directory will have the same format as a normal unpackaged deployment; you can specify classes, triggers, etc in this package.xml to include them in the package. Make sure you specify the types, as in:

<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <fullName>DemoPackage</fullName>
    <types>
        <name>ApexClass</name>
        <members>SomeClassName</members>
        <members>SomeClassNameTest</members>
    </types>
    <types>
        <name>CustomObject</name>
        <members>SomeCustomObject__c</members>
    </types>
    <version>44.0</version>
</Package>

You can include more than one package if you desire, each in their own folder, and specified in the root package.xml.

Make sure the fullName field follows the same rules as other API fields. You can read more about it in Package.

Alternatively, consider making a package in the UI, then do a retrieve to pull it down. You'll see the exact structure that the API expects.

  • Thank you for your time. I knew this process but the challenge we had with this approach was the actual metadata components were being updated interms of modified by and date. Our expectation s to create a unmanaged package in a salesforce org add the metadata which is already available on the same org without modifying anything on the actual metadata. – Srinivas Salloori Dec 27 '18 at 6:04

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.