2

A month ago I started work on a project, building custom Apex classes. For awhile, the project was small, and I could manage it via the Developer Console. That is, by copying-and-pasting my code from my text editor to the webforms in the Developer Console.

Now the project is getting bigger, and I can no longer keep track of things via the Developer Console. I am hoping to use Force-CLI to manage things from this point forward.

When I search Google for info about Force-CLI, there is a lot of information about "export" but very little about "import".

When I run this:

force export

I get a huge number files, including all of my custom classes. This is great.

Now I have made some changes to the files, and I'd like to send them back to Salesforce. I assume I can do:

force import -directory=metadata -c -r -v

and this should be fine.

I am curious though, if I have changed the name of files, does "force import" cause the old files to be deleted? I would prefer that, if possible, but I don't see that option. I would like an option that basically empowered me to say "If you don't see a file in my metadata directory, then please erase it from the project."

Is that possible?

And will "force import" generate the XML files for me?

1 Answer 1

2

If in doubt, go to the source - import.go.

As it stands now this command won't be smart enough to diff what you have locally with what is currently in Salesforce a perform the required destructive changes. It is going to do a standard Metadata API deploy call.

I think the best it can do is the -autoupdatepackage, -u option to:

Auto add files to the package if missing

Keep an eye of Salesforce DX for changes that will be happening in the future. Some of the developer tooling improvements with the new CLI will be closer to what you want to do.


There are a number of Salesforce IDE's that could also streamline your deployment process.

In the shameless self promotion category, my employer makes the free FuseIT SFDC Explorer tool. From v3.3 onwards in includes some tools for doing Metadata API deployments. It can monitor a directory for changes and autobuild the package.xml as you work on files. It doesn't do destructive changes automatically for you yet.

Something like Gearset would give you much richer functionality for doing deployments.

1
  • Thanks for this. I can't get 'force import' to work for me, but I'll ask about that in a separate question.
    – LRK9
    Nov 1, 2016 at 15:27

You must log in to answer this question.

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