Last active
February 13, 2023 16:01
-
-
Save iamsonal/1ce69f7e12b4feaafae821bb75839efe to your computer and use it in GitHub Desktop.
SFDX Commands
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--targetusername = -u (To specify a non-default scratch org) | |
--targetdevhubusername = -v (To specify a non-default Dev Hub org) | |
--setdefaultdevhubusername = -d | |
--setdefaultusername = -s | |
--instanceurl = -r | |
--setalias = -a | |
IMPORTANT: | |
1. You can use force:source:pull for scratch orgs only. If you’re synchronizing source to any other org, use the Metadata | |
API (force:mdapi:retrieve or force:mdapi:deploy). | |
2. The force:source:deploy, force:source:retrieve, and force:source:delete commands work on sandboxes, Developer Edition orgs, | |
and trial orgs, but not production orgs. For production orgs, continue to use force:mdapi:deploy and force:mdapi:retrieve. | |
---------------------------------------------------------------------------------------- | |
HELP | |
sfdx force:org:create --help | |
sfdx force:doc:commands:list | |
CREATE PROJECT | |
sfdx force:project:create --projectname mywork | |
sfdx force:project:create --projectname myproject --manifest | |
LOGIN | |
sfdx force:auth:web:login --setdefaultdevhubusername | |
sfdx force:auth:web:login --setdefaultdevhubusername --setalias DevHub | |
sfdx force:auth:web:login --setalias sandbox1 --instanceurl https://test.salesforce.com | |
LOGOUT | |
sfdx force:auth:logout -u [email protected] | |
sfdx force:auth:logout -a --noprompt (Log out all connected orgs) | |
CREATE DEFAULT SCRATCH ORG | |
sfdx force:org:create -f config/project-scratch-def.json --setalias sonalpsadevscratch --durationdays 30 --setdefaultusername | |
GET/SET local values for the project directory | |
sfdx force:config:list | |
sfdx force:config:get defaultusername defaultdevhubusername --json | |
sfdx force:config:set name=<value> | |
sfdx force:config:set instanceUrl= | |
sfdx force:config:set [email protected] (---> Set default username) | |
sfdx force:config:set [email protected] (---> Set default Dev Hub org) | |
SET ALIAS | |
sfdx force:alias:set [email protected] | |
OPEN DEFAULT ORG | |
sfdx force:org:open | |
sfdx force:org:open -u <username/alias> | |
DISPLAY ALL ORGS | |
sfdx force:org:list | |
sfdx force:org:list --clean (To remove non-active scratch orgs from the list) | |
DELETE SCRATCH ORG | |
sfdx force:org:delete -u tempTest | |
PUSH CODE To SCRATCH ORG | |
sfdx force:source:status | |
sfdx force:source:push | |
sfdx force:source:push --targetusername my-other-scratch-org | |
sfdx force:source:push --forceoverwrite | |
PULL CODE From SCRATCH ORG | |
sfdx force:source:status | |
sfdx force:source:pull | |
sfdx force:source:pull --forceoverwrite | |
VIEW LOCAL CHANGES | |
sfdx force:source:status --local | |
DEPLOY SINGLE FILE | |
sfdx force:source:deploy --loglevel fatal --sourcepath /Users/sonal/gsinternal-sfdx/force-app/main/default/classes/PSADataCreate.cls | |
sfdx force:source:deploy -p force-app/main/default/aura | |
sfdx force:source:deploy -p force-app -u [email protected] | |
RETRIEVE FILES | |
sfdx force:source:retrieve -p /Users/sonal/WebstormProjects/cg_salesforce/force-app/main/default/objects/CampaignMember/fields | |
sfdx force:source:retrieve -m ApexClass | |
sfdx force:source:retrieve -x path/to/package.xml | |
PACKAGE.XML | |
Create package.xml and save it in root directory. | |
Create folder mdapipkg in root directory. | |
sfdx force:mdapi:retrieve -r ./mdapipkg -u [email protected] -k ./package.xml | |
unzip mdapipkg/unpackaged.zip -d mdapipkg | |
Extract the zip file (mdapipkg/unpackaged/...) | |
sfdx force:mdapi:convert --rootdir mdapipkg | |
To deploy code in sandbox: | |
sfdx force:source:convert -d mdapi_output_dir --packagename [package name here] | |
sfdx force:mdapi:deploy --deploydir mdapi_output_dir --targetusername [email protected] | |
sfdx force:mdapi:deploy -w 1 -f mdZip/metadata.zip -u ${targetusernameOrAlias} | |
REFERENCES: | |
https://medium.com/@djrzo4/salesforcedx-123cc383a27e | |
sfdx force:source:retrieve -m PermissionSet |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
#!/bin/bash
if [ $# -lt 1 ]
then
echo Usage: generatepkgXML.sh orgalias packageName
exit
fi
Retrieve the PackageXML from Unmanaged Container
sfdx force:mdapi:retrieve -s -r ./mdapipkg -u $1 -p "$2" # Retrieve Metadata API Source from Package Name
unzip -o -qq ./mdapipkg/unpackaged.zip -d ./mdapipkg
rm -rf ./mdapipkg/unpackaged.zip
cd mdapipkg
git init
git add .
git commit -m "Initial commit"
#unzip -o -qq ./mdapipkg/unpackaged.zip -d ./mdapipkg # Unzip the file
#rm -rf ./manifest/ # If manifest directory exists delete it
#mkdir ./manifest/ # Create a New Manifest Directory
#cp -a ./mdapipkg/package.xml ./manifest/ # Copy package.XML to manifest directory
#rm -rf ./mdapipkg # Delete the mdapipkg source
sh ./generatepkgXML.sh vernicarnp Sample
sfdx force:mdapi:retrieve -s -r ./mdapipkg -u vernicarnp -p "Sample"
sfdx force:mdapi:retrieve -s -r ./mdapipkg -u StudentAppUAT -k ./mdapipkg/package.xml