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
benwrigleybenwrigley 

Deploying cross referencing classes

Does anyone know of a way to deploy classes that refer to each other?

 

I have a custom exception class and a custom email class. The email class instantiates and exception if anything goes wrong. Equally the exception class send an email to the system administrator if a serious exception is caught.

 

As a result, I cannot deploy these without commenting out great chunks of code first. Is there a sensible way to do this?

 

TIA

 

 

bob_buzzardbob_buzzard

I would expect you to be able to deploy both at the same time, either through change sets or by highlighting both in eclipse and right-clicking.

benwrigleybenwrigley

Unfortunately not. Deploying through force.com IDE both fail complaining that the other doesn't exist.

 

I thought the process uploaded everything, ran the tests for coverage, then reported on any issues. What this seems to show is that checks each class against the existing deployed classes.

bob_buzzardbob_buzzard

I've deployed related classes many times in the past without issue - it would be impossible to deploy large scale development otherwise.

 

Have you got any genuine test/compile failures?  That would cause the issue you are seeing.  E.g. if class A and class B depend on each other, if class A causes a test/compile failure, it is effectively rolled back.  Then class B will fail to compile as class A is no longer present.

benwrigleybenwrigley

Actually it's worse than that!

 

I am trying to deploy objects, pages, classes, tabs etc etc but to another sandbox for someone to test.

 

The list of error I get is very large as pages expect classes to exist and classes expect pages to exist, etc. So I am trying to deploy things area by area. Objects first, classes/pages next, tabs etc.

 

So I am already some way through this process of comments code but here is the current status. If I try to deploy all mu classes I get this in the logs:

 

 

# Deploy Results:
   File Name:    classes/TMDR_PriceBreak_Test.cls
   Full Name:  TMDR_PriceBreak_Test
   Action:  NO ACTION
   Result:  FAILED
   Problem: Invalid type: TMDR_PriceBreak

   File Name:    classes/TMDR_ShoppingCart_Test.cls
   Full Name:  TMDR_ShoppingCart_Test
   Action:  NO ACTION
   Result:  FAILED
   Problem: Invalid type: TMDR_ShoppingCart

   File Name:    classes/TMDR_Email_Test.cls
   Full Name:  TMDR_Email_Test
   Action:  UPDATED
   Result:  SUCCESS
   Problem: n/a

   File Name:    classes/TMDR_ErrorMessage_Test.cls
   Full Name:  TMDR_ErrorMessage_Test
   Action:  UPDATED
   Result:  SUCCESS
   Problem: n/a

   File Name:    classes/TMDR_ProfileDiscounts.cls
   Full Name:  TMDR_ProfileDiscounts
   Action:  UPDATED
   Result:  SUCCESS
   Problem: n/a

   File Name:    classes/TMDR_SalesOrder.cls
   Full Name:  TMDR_SalesOrder
   Action:  UPDATED
   Result:  SUCCESS
   Problem: n/a

   File Name:    classes/TMDR_User.cls
   Full Name:  TMDR_User
   Action:  UPDATED
   Result:  SUCCESS
   Problem: n/a

   File Name:    package.xml
   Full Name:  package.xml
   Action:  UPDATED
   Result:  SUCCESS
   Problem: n/a

   File Name:    pages/TMDR_SalesOrder.page
   Full Name:  TMDR_SalesOrder
   Action:  UPDATED
   Result:  SUCCESS
   Problem: n/a

# Test Results:
   n/a

 

Following the first failure through I try to deploy TMDR_PriceBreak before the others so that it won't complain. But trying to deploy that class complains that another called TMDR_Product does not exist.

 

So I try to deploy TMDR_Product first which complains that TMDR_PackageEntry doesn't exist.

 

Which complains that TMDR_Product doesn't exist (as these two refer to each other).

 

Then try TMDR_Product and TMDR_PackageEntry together and that was successful.

 

Back up the tree to TMDR_PriceBreak : success.

 

Back to trying all classes and pages again and now the error is reduced to

 

 

# Deploy Results:
   File Name:    classes/TMDR_ShoppingCart_Test.cls
   Full Name:  TMDR_ShoppingCart_Test
   Action:  NO ACTION
   Result:  FAILED
   Problem: Invalid type: TMDR_ShoppingCart

   File Name:    classes/TMDR_Email_Test.cls
   Full Name:  TMDR_Email_Test
   Action:  UPDATED
   Result:  SUCCESS
   Problem: n/a

   File Name:    classes/TMDR_ErrorMessage_Test.cls
   Full Name:  TMDR_ErrorMessage_Test
   Action:  UPDATED
   Result:  SUCCESS
   Problem: n/a

   File Name:    classes/TMDR_PriceBreak_Test.cls
   Full Name:  TMDR_PriceBreak_Test
   Action:  UPDATED
   Result:  SUCCESS
   Problem: n/a

   File Name:    classes/TMDR_ProfileDiscounts.cls
   Full Name:  TMDR_ProfileDiscounts
   Action:  UPDATED
   Result:  SUCCESS
   Problem: n/a

   File Name:    classes/TMDR_SalesOrder.cls
   Full Name:  TMDR_SalesOrder
   Action:  UPDATED
   Result:  SUCCESS
   Problem: n/a

   File Name:    classes/TMDR_User.cls
   Full Name:  TMDR_User
   Action:  UPDATED
   Result:  SUCCESS
   Problem: n/a

   File Name:    package.xml
   Full Name:  package.xml
   Action:  UPDATED
   Result:  SUCCESS
   Problem: n/a

   File Name:    pages/TMDR_SalesOrder.page
   Full Name:  TMDR_SalesOrder
   Action:  UPDATED
   Result:  SUCCESS
   Problem: n/a

# Test Results:
   n/a

 

 

 ...and the first error is resolved.

 

This is painful! I must be doing something wrong I guess. As you say, large scale deployments cannot be fun like this!

 

Thanks for any advice Bob

 

 

 

 

 

b-Forceb-Force

By using salesforce changeset deploy this two classses first .... and then deploy remaining part

 

 

Thanks,

bala

bob_buzzardbob_buzzard

Large scale deployments generally aren't fun.  They are getting easier with change sets, but its still a very time consuming and frustrating exercise.  I usually deploy visualforce pages, components and controller/utility classes as a single change set.  I usually find my change set number is up to around 10 by the time I find the correct combination that satisfies all the dependencies.  The list of errors is huge at the beginning, but often down to a single missing dependency causing many classes to fail to compile, meaning that the pages can't reference them, meaning other controllers can't see the pages etc etc

 

It sounds like you are heading in the right direction.  There's no silver bullet for this stuff - its down to endurance.

 

 

benwrigleybenwrigley

Good to know it's not just me then!

 

I guess the lesson here is to consider deployment when coding in dependencies. I thought coverage would be the only issue to worry about and dependencies would be managed as a bulk deployment .

 

Thanks for your help.

benwrigleybenwrigley

The plot thickens!

 

After what the IDE reports as a successful deployment of all Pages and Classes, I then tried to deploy tabs only to be told that a class was missing. Sure enough, that class had not been deployed, even though the IDE reported that it has been successful.

 

Is the IDE buggy when deploying?

 

 

 

bob_buzzardbob_buzzard

Not usually.  However, bearing in mind the recent move to Winter '11 there may be some issues around it.

benwrigleybenwrigley

I've managed it through the UI now and Change Sets. Seems much more effective.

 

Thanks again for your input.