From what i understand we basically need to re-parent the Attachments with Account Id
First migrate all as it is in current Org to the new org.
Then we can write a small snippet piece in execute anonymous to do the re-parenting .
I drafted a simple algorithm and you may need to tweak a little to get it working based on realtionship you have
1)Construct a map of Contract Id and Account Id(Map)(Query Contract )
2)Query all the attachments which you want to reparent with parent Id
3)From the parent Id (i.e Contract ) also using the map of Contract Id and Account Id you can obtain the Account Id
4)Update the attachments with parent Id equal to the attachment Id (Query and iterate through each to change the parent Id and collect in list and update the List )
5)Must be written in execute anonymous and executed (Try in sandbox first)
6)Hope you have less no of attachments not exceeding 10,000 ROWS
Map<Id,Id> mapofAcccIdIdbyContractId=new Map<Id,Id>();
Set<Id> setparentIds=new Set<Id> parentIds();
List<Attachment> lstattch=new List<Attachment>();
for(Attachment att:[SELECT Name, ID, ParentID WHERE Name LIKE '%.pdf']){
setparentIds.add(att.ParentID);
}
for(Contract ctr:[Select Id,AccountId from Contract where Id in:setparentIds]){
mapofAcccIdIdbyContractId.put(ctr.Id,Ctr.AccountId);
}
for(Attachment att:[SELECT Name, ID, ParentID WHERE Name LIKE '%.pdf']){
if(mapofAcccIdIdbyContractId.get(ParentID)!=null){
att.ParentID=mapofAcccIdIdbyContractId.get(ParentID);
lstattch.add(att);
}
}
update lstattch;
Best Answer
Its definitely possible using Forc.com migration tool or changset .
The changeset components will consists of the sharing rule both criteria and ownership based for custom and standard objects .Looks for them in the changeset.
If you want to move via Force.com IDE or ANT migration tool you can use package.xml
<?xml version="1.0" encoding="UTF-8"?> <Package xmlns="http://soap.sforce.com/2006/04/metadata"> <types> <members>ObjA__c.*</members> <name>SharingCriteriaRule</name> </types> <types> <members>ObjA__c.*</members> <name>SharingOwnerRule</name> </types> <version>39.0</version> </Package>
In force.com IDE you will see a folder named SharingRule that you can deploy to the other org .