2

I've got a problem in which I'm trying to deploy something whereby a field of type Number is being changed to a summary field.

What's happened is we created an object, Opportunity__c with two fields: Expected_Revenue__c and Expected_Vacancies__c, both were Number fields.

We also had another object called Opportunity_Forecast__c. Now the requirement has changed that the Expected_Revenue__c and Expected_Vacancies__c be a calculation of values entered in the forecast Object.

Now I've done all the switching around in a sandbox environment, but in validating the deployment I've got an error I half expected given we're changing metadata:

Cannot update a field to a Summary from something else

What's more problematic is that both Expected_Revenue__c and Expected_Vacancies__c are referenced by a Visualforce Page and Apex Classes.

The only way I can think to overcome this is to delete the classes, the Visualforce Page and the fields and just redeploy it, but I feel like this would be messy. Luckilly the object hasn't been used too much so it's not an issue. In a nutshell:

Is there an easier way to deploy changes to unrelated field types?

1
  • if you use ant, read about the various options for deletions (destructivechanges) and see if that helps
    – cropredy
    Jan 6, 2017 at 5:41

1 Answer 1

1

In the end, I had to use Salesforce Workbench to deploy some destrictive changesets using the following package.xml file:

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

And the following destructiveChanges.xml file:

<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>FirstController</members>
        <members>SecondController</members>
        <members>FirstControllerTest</members>
        <members>SecondControllerTest</members>
        <name>ApexClass</name>
    </types>
    <types>
        <members>FirstPage</members>
        <name>ApexPage</name>
    </types>
    <types>
        <members>My_Object__c.My_Field__c</members>
        <members>My_Object__c.My_Field__c</members>
        <name>CustomField</name>
    </types>
    <version>30.0</version>
</Package>

This was then packaged into a .zip file, then deployed in Workbench by going to:

Migration > Deploy

And making sure that the following settings were in place:

  • Rollback On Error: true
  • Single Package: true
  • Test Level: RunLocalTests

I'm not convinced this is the best way, but if anyone comes across a similar problem in the future, hopefully this will help!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .