Having outlined what we have learn from this bug, so what is #viewAllDiscoTopics? Earlier this year, just about the time when Spring '13 upgrade was being rolled out, we were trying to migrate from a pre-existing dev Sandbox to a newly-created testing Sandbox org using Force.com Migration Tool. However, when we try to deploy the retrieval into testing Sandbox, we received following, and rather cryptic, error message:
Unknown user permission: ViewAllDiscoTopicsAfter some Googling, I found out that this was one of the permission that was removed from Spring '13 release of Salesforce. As both the source and the destination orgs were Sandbox, and appears to have been upgraded, you would expect that either this permission should not have been included when the package was retrieved from the source org or should have been ignored by destination org when we were deploying it. However, as many of us who have used Force.com Migration Tool know, Force.com Migration Tool is something of all-or-nothing proposition where you have very limited control on what can be retrieved.
Given that one of the reasons Salesforce.com recommends the use of Force.com Migration Tool, one would expect that there must have been some automated process to remove this user permission from retrieved XML metadata file. Hence, I had opened a case and posted a question on Salesforce.com forum here. However, only answer I had received was to manually remove that tag from the XML file, as you can see from that discussion.
My Work-around
For our migration process, manually removing this tag every time we migrate just was not acceptable to us. Hence, I had written a small Python script with xml.etree.ElementTree to automatically remove any occurrence of userPermission tag whose child name node has viewAllDiscoTopics as its inner HTML value. I won't post the source code here as this is something that is simple to implement and could be implemented with pretty much any modern scripting language. However, I will post how I have set up my ant script to call to automatically call this removal script after retrieval as I suspect many of us are not familiar with it as Makefile.
As a first step to automate the tag removal, I added following ant target to call my Python script:
<target name="removeTags">After that, I modified my custom target to automate the retrieval and deployment to call this target prior to deploying the retrieval to destination org:
<exec executable="python">
<arg value="removeViewAllDiscoTopics.py" />
</exec>
</target>
<target name="deployAll">
<antcall target="retrieve" />
<antcall target="removeTags" />
<antcall target="deploy" />
</target>
Take-away
Now, this does address the problem automating removal of this particular bug. However, this does not address the underlying problem that you need to be aware of presence of such bugs and you have to create scripts to remove all occurrences of such bugs, which is clear limitation of the tool. Also, using a custom script to massage the retrieved XML is something that I had to do to address other limitations of Force.com Migration Tool, and I will revisit this solution in future posts. Finally, this is something that occurred precisely because the deployment happen during the Salesforce upgrade window. This is something that is mentioned in recent Force.com webinar on deploy: From Sandbox to Production: Demystifying Force.com Release Management Part 1. The suggestion from Salesforce.com in that webinar is to avoid deployment during the upgrade window, which is not practical for many enterprises due to their business cycle and which exposes one of the major limitation of Salesforce.com.