0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Salesforce組織からソースを取得

Posted at

Salesforce組織側でのみ保持しているApexソースを、VSCodeを使った統合開発環境上に取得する際にCLIの実行が必要だったので、その内容を記載します。
(VSCode>Salesforce Extension Packの「SFDX:組織からソースを取得」では取得できませんでした)

VSCodeのSalesforce Extension Packでは解決ができていないようなので、CLI側で解決しました。(該当ヘルプは下記の通りです)
また、一度ソース取得を行うとVSCode側の「SFDX:組織からソースを取得」からでも取得ができるようになりました。

$ sfdx force:source:retrieve --help
retrieve source from an org

USAGE
$ sfdx force:source:retrieve [-p | -x | -m ] [-w ] [-n ] [-u ] [-a ] [--verbose] [--json] [--loglevel
trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]

OPTIONS
-a, --apiversion=apiversion override the api version used for api requests made by this command
-m, --metadata=metadata comma-separated list of metadata component names
-n, --packagenames=packagenames a comma-separated list of packages to retrieve
-p, --sourcepath=sourcepath comma-separated list of source file paths to retrieve
-u, --targetusername=targetusername username or alias for the target org; overrides default target org
-w, --wait=wait [default: [object Object]] wait time for command to finish in minutes
-x, --manifest=manifest file path for manifest (package.xml) of components to retrieve
--json format output as json
--loglevel=(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL) [default: warn] logging level for this command invocation
--verbose verbose output of retrieve result

DESCRIPTION
Use this command to retrieve source (metadata that’s in source format) from an org.
To take advantage of change tracking with scratch orgs, use "sfdx force:source:pull".
To retrieve metadata that’s in metadata format, use "sfdx force:mdapi:retrieve".

The source you retrieve overwrites the corresponding source files in your local project. This command does not attempt to merge the source from your org with your local source files.

If the comma-separated list you’re supplying contains spaces, enclose the entire comma-separated list in one set of double quotes. On Windows, if the list contains commas, also enclose it in one set of double quotes.

EXAMPLES:
To retrieve the source files in a directory:
$ sfdx force:source:retrieve -p path/to/source

To retrieve a specific Apex class and the objects whose source is in a directory:
$ sfdx force:source:retrieve -p "path/to/apex/classes/MyClass.cls,path/to/source/objects"

To retrieve source files in a comma-separated list that contains spaces:
$ sfdx force:source:retrieve -p "path/to/objects/MyCustomObject/fields/MyField.field-meta.xml, path/to/apex/classes

To retrieve all Apex classes:
$ sfdx force:source:retrieve -m ApexClass

To retrieve a specific Apex class:
$ sfdx force:source:retrieve -m ApexClass:MyApexClass

To retrieve all custom objects and Apex classes:
$ sfdx force:source:retrieve -m "CustomObject,ApexClass

To retrieve all Apex classes and two specific profiles (one of which has a space in its name):
$ sfdx force:source:retrieve -m "ApexClass, Profile:My Profile, Profile: AnotherProfile"

To retrieve all metadata components listed in a manifest:
$ sfdx force:source:retrieve -x path/to/package.xml

To retrieve metadata from a package or multiple packages:
$ sfdx force:source:retrieve -n MyPackageName
$ sfdx force:source:retrieve -n "Package1, PackageName With Spaces, Package3"

To retrieve all metadata from a package and specific components that aren’t in the package, specify both -n | --packagenames and one other scoping parameter:
$ sfdx force:source:retrieve -n MyPackageName -p path/to/apex/classes
$ sfdx force:source:retrieve -n MyPackageName -m ApexClass:MyApexClass
$ sfdx force:source:retrieve -n MyPackageName -x path/to/package.xml

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?