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
JohnnyV!JohnnyV! 

Force (Ant) Migration Tool & Issues with layouts

I have been working with the Force Migration Tool and am experiencing issues with trying to do a full refresh from one sandbox to another.  The following errors are appearing when I try to call sf:deploy:

1.  layouts/FeedItem-Feed Item Layout.layout -- Error: Layout must have at least 1 section

2.  layouts/SocialPost-Social Post Layout.layout -- Error: Parent entity failed to deploy

3.  layouts/UserAlt-User Profile Layout.layout -- Error: Cannot use field:Name in a layout

4.  workflows/Question.workflow -- Error: Cannot create workflow directly; must create the CustomObject first

5.  workflows/Reply.workflow -- Error: Cannot create workflow directly; must create the CustomObject first

6.  workflows/SocialPost.workflow -- Error: Cannot create workflow directly; must create the CustomObject first

My approach has been to use sf:retrieve to get the metadata from the src\ folder and place it into a localCopy folder.  (The src\ files are the files checked into Git from the source Sandbox.)  Next, I have been using sf:deploy to use the files in the localCopy folder to refresh the target Sandbox.  When I run the sf:retrieve task, I am getting the six errors listed above.

I should point out that the items noted in the six errors (above) are not elements that we have made changes to.  My goal is to make the sf:retrieve and sf:deploy processes more generic, to simply push everything (that I can) from the source to the target Sandboxes.  Hopefully this is an obtainable goal.  :)

I can remove these six elements manually, but then I start getting errors with the referenes in the profiles.  If I leave out the profiles too, then my code deploys, but none of the permissions are getting set ... to things like Custom Fields in the Lead object (for example).  Ugh!

I am very new to Salesforce and to the Force Migration Tool ... so any help that can be provided would be very much appreciated.

Thank you for your time!
jv
Best Answer chosen by JohnnyV!
JohnnyV!JohnnyV!
Thanks Andy for your reply ... I found a link on StackOverview where other individuals were having this same issue.  

http://salesforce.stackexchange.com/questions/54458/feeditem-feed-item-layout-preventing-profile-deployment

Basically, the Ant Regex command was used to remove the un-migrateable (I really don't think that is a word) elements from the .profile records.  Then, a second task was created to delete the un-migrateable (sorry again) files.  Once I got the Regex working, my migration was working without any issues.

Here is some information from my build.xml that was used to do the regex and the delete:
 
<target name="remove_profile_references">
      <echo message="removing references that cannot be migrated from all profiles" />
      <replaceregexp
        match="^    &lt;layoutAssignments&gt;\n        &lt;layout&gt;(FeedItem-Feed Item Layout|SocialPost-Social Post Layout|UserAlt-User Profile Layout|SocialPersona-Social Persona Layout)&lt;/layout&gt;\n    &lt;/layoutAssignments&gt;$"
        replace=""
        flags="gm"
        byline="false">
        <fileset
          dir="localCopy\profiles"
          includes="**/*.profile"
        />
      </replaceregexp>
      <replaceregexp
        match="^    &lt;tabVisibilities&gt;\n        &lt;tab&gt;standard-SocialPersona&lt;/tab&gt;\n        &lt;visibility&gt;DefaultOff&lt;/visibility&gt;\n    &lt;/tabVisibilities&gt;$"
        replace=""
        flags="gm"
        byline="false">
        <fileset
          dir="localCopy\profiles"
          includes="**/*.profile"
        />
      </replaceregexp>     
    </target>
    <target name="delete_unmigrateable_files" depends="remove_profile_references">
      <echo message="removing files that cannot be migrated" />
      <delete file="localCopy/layouts/FeedItem-Feed Item Layout.layout"/>
      <delete file="localCopy/layouts/SocialPost-Social Post Layout.layout"/>
      <delete file="localCopy/layouts/UserAlt-User Profile Layout.layout"/>
      <delete file="localCopy/workflows/Question.workflow"/>
      <delete file="localCopy/workflows/SocialPost.workflow"/>
      <delete file="localCopy/workflows/Reply.workflow"/>
    </target>

The target/task to perform the sf:deploy has a depency on the delete_unmigrateable_files task, which has a dependency on remove_profile_references.

Hopefully, this information benefits someone else.  :)
 

All Answers

Andy BoettcherAndy Boettcher
The Force.com Migration Tool (as with any Metadata deploys) are tricky - you cannot just pull one or two components out, everything is relative and cumulative.  Judging by the errors above - you're not pulling ALL metadata out of the org, perhaps just Workflows, Layouts, and from your description - Profiles.  You have to get EVERYTHING.
JohnnyV!JohnnyV!
Thanks Andy for your reply ... I found a link on StackOverview where other individuals were having this same issue.  

http://salesforce.stackexchange.com/questions/54458/feeditem-feed-item-layout-preventing-profile-deployment

Basically, the Ant Regex command was used to remove the un-migrateable (I really don't think that is a word) elements from the .profile records.  Then, a second task was created to delete the un-migrateable (sorry again) files.  Once I got the Regex working, my migration was working without any issues.

Here is some information from my build.xml that was used to do the regex and the delete:
 
<target name="remove_profile_references">
      <echo message="removing references that cannot be migrated from all profiles" />
      <replaceregexp
        match="^    &lt;layoutAssignments&gt;\n        &lt;layout&gt;(FeedItem-Feed Item Layout|SocialPost-Social Post Layout|UserAlt-User Profile Layout|SocialPersona-Social Persona Layout)&lt;/layout&gt;\n    &lt;/layoutAssignments&gt;$"
        replace=""
        flags="gm"
        byline="false">
        <fileset
          dir="localCopy\profiles"
          includes="**/*.profile"
        />
      </replaceregexp>
      <replaceregexp
        match="^    &lt;tabVisibilities&gt;\n        &lt;tab&gt;standard-SocialPersona&lt;/tab&gt;\n        &lt;visibility&gt;DefaultOff&lt;/visibility&gt;\n    &lt;/tabVisibilities&gt;$"
        replace=""
        flags="gm"
        byline="false">
        <fileset
          dir="localCopy\profiles"
          includes="**/*.profile"
        />
      </replaceregexp>     
    </target>
    <target name="delete_unmigrateable_files" depends="remove_profile_references">
      <echo message="removing files that cannot be migrated" />
      <delete file="localCopy/layouts/FeedItem-Feed Item Layout.layout"/>
      <delete file="localCopy/layouts/SocialPost-Social Post Layout.layout"/>
      <delete file="localCopy/layouts/UserAlt-User Profile Layout.layout"/>
      <delete file="localCopy/workflows/Question.workflow"/>
      <delete file="localCopy/workflows/SocialPost.workflow"/>
      <delete file="localCopy/workflows/Reply.workflow"/>
    </target>

The target/task to perform the sf:deploy has a depency on the delete_unmigrateable_files task, which has a dependency on remove_profile_references.

Hopefully, this information benefits someone else.  :)
 
This was selected as the best answer