Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 6 Current »

As of Summer '20 you can now do source tracking in Sandboxes. That is push and pull from Sandboxes and SFDX will track the changes made in your sandbox.

Now it’s only Developer and Developer Pro Sandboxes and the Sandbox must be refreshed AFTER Summer '20 is released.

Here’s the documentation. There is a new Object in the org named SourceMember.

However, before you start go to Dev Hub in setup and Enable Source Tracking. You don’t need to enable Dev Hub.

I would run an SFDX Update before doing this. Ensure you are on API Version 49 and I would create a new SFDX Project for the new Sandbox.

Setup

So you create your sandbox. Log into your sandbox. Then create a new Project in VSCode and then run

sfdx force:auth:web:login -r https://test.salesforce.com -a yourAlias

The next thing you expect to do is

sfdx force:source:status -u yourAlias

And that this would show you all of your org’s metadata and then you would pull ALL your Sandbox’s metadata from your Sandbox to your VS Code, right? Right? Nope. Nothing.

Sooo, we are back being left with creating a package.xml and downloading the Sandbox config first. You would think Org Browser would do it but no, Org Browser does not work with Managed Packages installed in your org, and no matter what the Salesforce DX team say, a real org is very likely to have customisations built on top of managed packages - eg NPSP. And you can’t easily bring down ALL your org with Org Browser. Again it’s only suited to devs who use two or three types of metadata.

So I like Salesforce Package.xml Generator Extension. It’s about as easy, and about as slow as the old way of doing things in MavensMate.

So once you have your package.xml file run

sfdx force:source:retrieve -x force-app\manifest\package.xml

And of course it takes forever.

After that immediately do a

sfdx force:source:status -u yourAlias

To find out all the metadata you added.

Oops. As per usual with working with DX you can get yourself into trouble.

I try to pull changes and of course it says no changes to pull.

I try to push changes (with no changes made) and it has an error.

ERROR running force:source:push: Expected file at path: C:\MyFolder\force-app\manifest\package.xml-meta.xml

Now i have never seen a package.xml-meta.xml file so I don’t know what that means.

What have I done wrong?

OK, so firstly I was on a pre-release version of the Salesforce CLI. Run sfdx plugins --core to check the version, then run these commands to fix it. See the SFDX Release Notes.

sfdx plugins --core sfdx plugins:uninstall salesforcedx sfdx update sfdx plugins --core

Then you can reset your tracking

sfdx force:source:tracking:reset

Then I did a push again and it worked

Thanks to Miles Robson for that trick to reset.

Suggested Process

  • Update your production org’s package.xml to the latest version and ensure that you can do a retrieve from production under the latest API version. Ensure your Source is up to date.

  • Commit your production source to your repo, just to back it up.

  • Save that whole folder as a new folder.

  • Refresh your sandbox

  • Authorise the sandbox from that new folder.

  • (optionally) run sfdx force:source:tracking:reset I’m not quite sure yet if it is needed.

  • Start making some changes in your org or the metadata

  • Push and / or pull as required

Make Some Changes

TBA.

Query what changes there are

Query the status of your changes using SOQL https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_sandboxes_source_tracking_sourcemember.htm

SELECT MemberName, MemberType, ChangedBy, RevisionCounter FROM SourceMember

But use the Tooling API.

  • No labels