Deploying from a development org to a new unrelated org without a package

Ben Dixon picture Ben Dixon · Dec 2, 2013 · Viewed 7.4k times · Source

I've been struggling with the deployment of our force.com application code that has, up to now, been developed in a single development org I'll call DevOrg.

What I want to do is transfer the DevOrg objects, code, pages, etc from DevOrg to a sandbox in a new org (NewOrg) that I have created. NewOrg and its sandbox are devoid of any code/objects related to the application. I've used the migration tool to retrieve the code from DevOrg and have fashioned the package.xml in various ways to get the code to deploy the NewOrg sandbox, but I keep getting tons of errors, for example:

 [sf:deploy]  SomeClass: line 1014, column 95: Dependent class is invalid and needs recompilation:
 [sf:deploy]  SomceClass2: line 475, column 37: Dependent class is invalid and needs recompilation:

I went into the Eclipse IDE and checked out the project from DevOrg, exported the project and imported it to a project pointed to NewOrg's sandbox. I thought perhaps this would give me hints about a working package.xml since I can work in the DevOrg project in the Eclipse IDE without any problems/errors.

But instead I found the same errors in the NewOrg sandbox project when loaded within the IDE. So I tried making adding a space to the dependent class and saving it to the NewOrg sandbox and I received an sObject error like this:

Save error: 
sObject type 'SomeClass__c' is not supported. 
If you are attempting to use a custom object, be sure to append the '__c' after the entity name. 
Please reference your WSDL or the describe call for the appropriate names.

Thinking this must be because the objects haven't been deployed to NewOrg's sandbox, I attempted to the deploy only the objects in the project. That too failed. This time with errors like this:

Save error:
Appointment_Type_Form__c.Form__c : referenceTo value of 'Form_Template__c' 
does not resolve to a valid sObject type Appointment_Type_Form__c.object 

Save error:
Form__c : Cannot set ControlledByParent on a CustomObject without a 
MasterDetail relationship field Form__c.object

Save error:
Form__c.All : In field: columns - no CustomField named 
Form__c.Form_Template__c found   Form__c.object

Save error:
Form__c.Form_Template__c : referenceTo value of 'Form_Template__c'
 does not resolve to a valid sObject type Form__c.object

Save error:
Form_Template__c : formoverride does not exist or is not 
a valid override for action Edit.  Form_Template__c.object

Save error:
GWAPI_Log__c : log_detail does not exist or is not 
a valid override for action View.    GWAPI_Log__c.object

Save error:
Idea.Ideas_Last_7_Days : Could not resolve list 
view column: IDEA.IDEA_THEME    Idea.object

Save error:
Message__c.Form_in_Question__c : referenceTo value of 'Form_Template__c'
 does not resolve to a valid sObject type   Message__c.object

Save error:
News__c : customarticle does not exist or is not a valid override
for action Edit.  News__c.object

Save error:
Question__c : Cannot set ControlledByParent on a CustomObject without
 a MasterDetail relationship field Question__c.object

Save error:
Question__c.All : In field: columns - no CustomField named 
Question__c.Form_Template__c found   Question__c.object

Save error:
Question__c.Form_Template__c : referenceTo value of 'Form_Template__c'
 does not resolve to a valid sObject type Question__c.object

Save error:
Section__c : Cannot set ControlledByParent on a CustomObject without
 a MasterDetail relationship field  Section__c.object

Save error:
Section__c.Form_Template__c : referenceTo value of 'Form_Template__c' 
does not resolve to a valid sObject type  Section__c.object

Save error:
Security_Question_Answer__c.Question_Text__c : Field Is_Patient__c 
does not exist. Check spelling.  Security_Question_Answer__c.object

Save error:
sObject type 'Portal_Session__c' is not supported. If you are 
attempting to use a custom object, be sure to append the '__c' 
after the entity name. Please reference your WSDL or the describe call for the appropriate names.

And so I have to have any luck with the new deployment in either the IDE or via the Migration Tool (MT).

I'm looking for advice on how to approach these issues when deploying to a brand new org using either IDE or MT. The errors imply, I think, something about the ordering of the deployment but as I understand from the Migration Tool Guide, Development Lifecycle Guide, etc the dependencies and ordering can be determined by the platform when deploying.

Have others run into similar issues and found that the solution was strictly in the package.xml? I'm curious because in one instance the package.xml works fine (when deploying to the original org) but in the other case (a new org) it doesn't seem sufficient.

Answer

Pavel Slepiankou picture Pavel Slepiankou · Dec 2, 2013

The troubles with a virgin sandboxes is that usually you can't deploy it without a few iterations.

I used the following workflow:

  1. deploy the custom objects which are on relationships with standard objects
  2. deploy standard sObjects
  3. deploy the rest of sObjects
  4. deploy triggers and apex code
  5. deploy VF pages/VF email templates
  6. deploy the rest of metadata

after that I used only migration tool for deployment.

I'd like to suggest you perform deployment of sObjects by one at a time for most significant objects. Also before the deployment please check that all settings of standard objects conform to DevOrg's settings

Also you can try to change API version of metadata.