Salesforce has two differnt formats to store code/metadata now.
Conventional Metadata
format and new Source
/SFDX format.
Usually you can tell the format from folder structure and file format. If code is following some folder structure like
force-app/main/default
usually it will be in source format. But is it not guaranteed.
A better way to confirm is to check object and field metadata files.
If field metadata is included inside a .object
file, that means that the code is in metadata format.
In source/SFDX format, field metadata will be separated into separate files
Script to deploy source format code to sandboxes
Even if we use scratch orgs for development, we still need to use sandboxes for testing, UAT, training etc. We need to convert code in source format to metadata format before can properly deploy the whole codebase to these sandboxes or production. Use below shell script to make this metadata conversion and deployment easy.
How to use
- Create a shell file with .sh extension inside your project folder and copy paste above code.
- Make the file executable with
sudo chmod u+x pathToTheShellFileHere
. - Authenticate your sandboxes/production using
sfdx force:auth:web:login
command - Now to deploy you can navigate to the project folder and run
./shellFileName.sh
. It will ask for alias of the environment that you want to deploy to. Enter the alias and hit enter. Deployment starts.
Please note that this shell script works in Mac terminal and Linux shell only. If you are using windows, you can try to use bash shell there or write windows versions of the commands into a .bat file.
Really enjoyed this article.Much thanks again. Want more
ReplyDeletesalesforce training
salesforce online training