salesforce - sf - sfdx - cli - commands

1. Command for retrieving all Aura Components


SF project retrieve start -m AuraDefinitionBundle


2. command for retrieving all lwc components


SF project retrieve start -m LightningComponentBundle


3. command for retrieve all apex class


sf project retrieve start --metadata 'ApexClass:*' 


4. command for login to org


sf org login web -a MyAlias      (here "MyAlias" is a dynamic and unique identification of our choice)


5. command for login to org using session id


sf org login access-token --instance-url <instance_url> --access-token <access_token>


eg: sf org login access-token --instance-url https://login.salesforce.com --access-token 00Dxx0000000000!AQMAQKr0MSLIGgDg


6. command to get apex class ID


sf data query --query "SELECT Id, Name FROM ApexClass WHERE Name = 'ApexClassName'"


7. scenario: if a class has code coverage by hundreds of classes and if we would like to find high code coverage class-method-codeCoverageLines


i)sf data query --use-tooling-API --query "SELECT ApexTestClassId, TestMethodName, NumLinesCovered, NumLinesUncovered FROM ApexCodeCoverage WHERE ApexClassOrTriggerId = '01p4I000009x8bDQAQ'"


8. command for running all test classes


sf apex run test --test-level RunLocalTests --output-dir <path to outputdir> --target-org me@my.org


9. command for running specific test methods from specific classes


sf apex run test --tests MyClassTest.testCoolFeature --tests MyClassTest.testAwesomeFeature --tests AnotherClassTest --tests namespace.TheirClassTest.testThis --result-format human


10. the command for running specific test methods from a specific class


sf apex run test --tests MyClassTest.testCoolFeature --result-format human


11. To view the salesforce session ID and domine name in vs code (if already authenticated salesforce org)


sf org display --target-org <username-or-alias>


12. Command to retrieve all validation rules --------- 


sf project retrieve start -m ValidationRule


13. Command to create lwc component - SF command to create lwc component


sf lightning generate component --type lwc --name SLAInformation --output-dir force-app/main/default/lwc


14. Command to deploy lwc component - SF command to deploy lwc component


SF project deploy start --metadata LightningComponentBundle:sLAInformation


Note: Make sure the component name is the same after creation. are you deploying or else you will get an error like: "No source-backed components present in the package."


15. Command to Authorise Salesforce Org - SF command to web login


sf org login web --alias sktech --instance-url https://skcloud-dev-ed.develop.my.salesforce.com


note :

sketch - org alias name 

https://skcloud-dev-ed.develop.my.salesforce.com - give here ur instance URL


16. Retrieve All MetaData Components From salesforce to the local system


sf project generate manifest --output-dir manifest --name=allMetadata --from-org [your org alias]


Note:  then which will retrieve all metadata components names to a file "allMetadata.xml" --> open it in vs code -->  right click on opened file -->  "retrieve this source from org"  -- > then all the metadata components will retrieve from salesforce to local computer.



17. Logout from all orgs


sf org logout --all


18. uninstall sfdx - SF - cli  - salesforce


npm uninstall sfdx-cli --global


19 Logout from particular org using sf command


sf org logout --target-org AlisName






Comments

Popular posts from this blog

How to get sessionid and salesforce org base url in salesforce

Multi currency in Salesforce - Revenue Cloud Advance - Revenue Lifecycle Management