0

I am trying to move metadata through ANT tool, data also retrieved but at the time of deploying the data to another sandbox it is showing error like :

All Component Failures:

triggers/AfterUpdateOnOpportunity.trigger -- Error: Invalid type: OpportunityEventProcessor (line 6, column 3)

triggers/BeforeInsertOnTierInfo.trigger -- Error: Invalid type: Schema.Tier_Info__c (line 1, column 9)

triggers/BeforeInsertOnAggregateRates.trigger -- Error: Invalid type: Schema.Aggregate_Rate__c (line 1, column 9)

*********** DEPLOYMENT FAILED ***********

Can you please suggest me, where I am going wrong at the deploying process:

<project name="Sample usage of Salesforce Ant tasks" default="test" basedir="." xmlns:sf="antlib:com.salesforce">

    <property file="build.properties"/>
    <property environment="env"/>

<!-- Setting default value for username, password and session id properties to empty string 
     so unset values are treated as empty. Without this, ant expressions such as ${sf.username}
     will be treated literally.
-->
<condition property="sf.username" value=""> <not> <isset property="sf.username"/> </not> </condition>
<condition property="sf.password" value=""> <not> <isset property="sf.password"/> </not> </condition>
<condition property="sf.sessionId" value=""> <not> <isset property="sf.sessionId"/> </not> </condition>

<taskdef resource="com/salesforce/antlib.xml" uri="antlib:com.salesforce">
    <classpath>
        <pathelement location="../ant-salesforce.jar" />          
    </classpath>
</taskdef>

<!-- Test out deploy and retrieve verbs for package 'mypkg' -->
<target name="test">
  <!-- Upload the contents of the "mypkg" package -->
  <sf:deploy username="${sf.username}" password="${sf.password}" sessionId="${sf.sessionId}" serverurl="${sf.serverurl}" maxPoll="${sf.maxPoll}" deployRoot="mypkg" rollbackOnError="true"/>
  <mkdir dir="retrieveOutput"/>
  <!-- Retrieve the contents into another directory -->
  <sf:retrieve username="${sf.username}" password="${sf.password}" sessionId="${sf.sessionId}" serverurl="${sf.serverurl}" maxPoll="${sf.maxPoll}" retrieveTarget="retrieveOutput" packageNames="MyPkg"/>
</target>

<!-- Retrieve an unpackaged set of metadata from your org -->
<!-- The file unpackaged/package.xml lists what is to be retrieved -->
<target name="retrieveUnpackaged">
  <mkdir dir="retrieveUnpackaged"/>
  <!-- Retrieve the contents into another directory -->
  <sf:retrieve username="${sf.username}" password="${sf.password}" sessionId="${sf.sessionId}" serverurl="${sf.serverurl}" maxPoll="${sf.maxPoll}" retrieveTarget="retrieveUnpackaged" unpackaged="unpackaged/package.xml"/>
</target>

<!-- Retrieve all the items of a particular metadata type -->
<target name="bulkRetrieve">
  <sf:bulkRetrieve username="${sf.username}" password="${sf.password}" sessionId="${sf.sessionId}" serverurl="${sf.serverurl}" maxPoll="${sf.maxPoll}" metadataType="${sf.metadataType}" retrieveTarget="retrieveUnpackaged"/>
</target>

<!-- Retrieve metadata for all the packages specified under packageNames -->
<target name="retrievePkg">
  <sf:retrieve username="${sf.username}" password="${sf.password}" sessionId="${sf.sessionId}" serverurl="${sf.serverurl}" maxPoll="${sf.maxPoll}" retrieveTarget="retrieveOutput" packageNames="${sf.pkgName}"/>
</target>

<!-- Deploy the unpackaged set of metadata retrieved with retrieveUnpackaged and run tests in this organization's namespace only-->
<target name="deployUnpackaged">
  <sf:deploy username="${sf.username}" password="${sf.password}" sessionId="${sf.sessionId}" serverurl="${sf.serverurl}" maxPoll="${sf.maxPoll}" deployRoot="retrieveUnpackaged" rollbackOnError="true"/>
</target>

<!-- Deploy a zip of metadata files to the org -->
<target name="deployZip">
  <sf:deploy username="${sf.username}" password="${sf.password}" sessionId="${sf.sessionId}" serverurl="${sf.serverurl}" maxPoll="${sf.maxPoll}" zipFile="${sf.zipFile}" pollWaitMillis="1000" rollbackOnError="true"/>
</target>

<!-- Shows deploying code & running tests for code in directory -->
<target name="deployCode">
  <!-- Upload the contents of the "codepkg" directory, running the tests for just 1 class -->
  <sf:deploy username="${sf.username}" password="${sf.password}" sessionId="${sf.sessionId}" serverurl="${sf.serverurl}" maxPoll="${sf.maxPoll}" deployRoot="codepkg" testLevel="RunSpecifiedTests" rollbackOnError="true">
     <runTest>SampleDeployClass</runTest> 
  </sf:deploy>
</target>
<!-- Shows removing code; only succeeds if done after deployCode -->
<target name="undeployCode">
  <sf:deploy username="${sf.username}" password="${sf.password}" sessionId="${sf.sessionId}" serverurl="${sf.serverurl}" maxPoll="${sf.maxPoll}" deployRoot="removecodepkg"/>
</target>

<!-- Shows retrieving code; only succeeds if done after deployCode -->
<target name="retrieveCode">
  <!-- Retrieve the contents listed in the file codepkg/package.xml into the codepkg directory -->
  <sf:retrieve username="${sf.username}" password="${sf.password}" sessionId="${sf.sessionId}" serverurl="${sf.serverurl}" maxPoll="${sf.maxPoll}" retrieveTarget="codepkg" unpackaged="codepkg/package.xml"/>
</target>

<!-- Shows deploying code, running all tests, and running tests (1 of which fails), and logging. -->
<target name="deployCodeFailingTest">
  <!-- Upload the contents of the "codepkg" package, running all tests -->
  <sf:deploy username="${sf.username}" password="${sf.password}" sessionId="${sf.sessionId}" serverurl="${sf.serverurl}" maxPoll="${sf.maxPoll}" deployRoot="codepkg" testLevel="RunAllTestsInOrg" rollbackOnError="true" logType="Debugonly"/>
</target>

<!-- Shows check only; never actually saves to the server -->
<target name="deployCodeCheckOnly">
  <sf:deploy username="${sf.username}" password="${sf.password}" sessionId="${sf.sessionId}" serverurl="${sf.serverurl}" maxPoll="${sf.maxPoll}" deployRoot="codepkg" checkOnly="true"/>
</target>
  • Where is the class OpportunityEventProcessor declared ? Other than that, could you please add the line of code on which you use Schema ? It's a native class and should be considered as a reserved keyword (like when people use the keyword Test). Could you please give more inputs ? – Answers_Seeker Nov 26 '18 at 14:08
2

You neglected to include the related objects, Aggregate_Rate__c and Tier_Info__c. Make sure these files are in the objects/ directory and included in the package.xml file. Make sure you get all the required elements.

  • Yes, I have these Aggregate_Rate__c and Tier_Info__c files in my object directory and package.xml too – Harshit Nov 26 '18 at 13:09
  • @Harshit Either you have additional component errors, or you're missing something else. It should work if you had a full package. Try using the package manager (Setup > Create > Packages) to build a full, proper package. – sfdcfox Nov 26 '18 at 13:11
  • I am using the sandbox, should I have to sign up in developer edition for creating packages – Harshit Nov 27 '18 at 9:24
  • @Harshit You can create packages in a Sandbox. They are useful for when you want to make sure you don't miss any metadata, as is the situation here. – sfdcfox Nov 27 '18 at 14:41

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.