Tuesday, February 15, 2022

Friday, September 17, 2021

SFDX running apex scripts

This bash script will help you launch apex scripts.

To launch the scripts, is using the command:

sfdx force:apex:execute -u <alias> -f <script.apex> 

link: https://github.com/d2269/SFScripts/tree/main/bash/running_apex_scripts 

Script:

Friday, September 10, 2021

Get test coverage from sandbox

Often, for a correct deployment, we need to know the test coverage of the apex code.
This is especially true for deployment using RunSpecifiedTests.
To do this, you can use the salesforce developer console.




But in order to give it to programmers to work, you need to get the test coverage of classes.

The SOQL query will help you with this:

To get the test coverage of classes and triggers, use 2 commands

1st (you will only get the aggregate coverage)
SOQL (with tooling API)

select ApexClassOrTrigger.Name, NumLinesUncovered, NumLinesCovered FROM ApexCodeCoverageAggregate

 
sfdx force:data:soql:query --query "select ApexClassOrTrigger.Name, NumLinesUncovered, NumLinesCovered FROM ApexCodeCoverageAggregate" --targetusername <alias> --usetoolingapi --resultformat csv > classes.csv

 
2nd (you will get the value of how many rows each method of each test class covers)
SOQL (with tooling API)

select ApexTestClass.Name, TestMethodName, ApexClassOrTrigger.Name, NumLinesUncovered, NumLinesCovered FROM ApexCodeCoverage

 
sfdx force:data:soql:query --query "select ApexTestClass.Name, TestMethodName, ApexClassOrTrigger.Name, NumLinesUncovered, NumLinesCovered FROM ApexCodeCoverage" --targetusername <alias> --usetoolingapi --resultformat csv > classesAandMethods.csv




Friday, September 3, 2021

Monday, August 30, 2021

Mass delete unused flow and process builder versions in Salesforce

Many people wonder how to remove inactive versions flow and process builder.

I also had such a problem as the deployment went all over the branch and the versions accumulatedvery quickly especially on the integration environment.

Hope this helps you.

The URL is the address of your org.

Version restriction made to not touch the old versions.

You can upgrade the query as you like. 

New version for removing flaw from the sandbox using an array.
Added a feature: do not delete the last N versions from the active version.
link 

Execute Anonymous Window:

Thursday, August 26, 2021

Example of a Release and Git strategy

Release Strategy

The release scheme is designed taking into account the specifics of the project and the amount of development.

Main features:

-          source of truth git;

-          Interaction with other vendors via git;

-          maximum transparency of changes;

-          minimum labor costs for deployment;

-          deep automation is possible;

Monday, August 23, 2021

How to find deployed Components in an Org with Deployment ID?

You can use the Rest Explorer in Workbench (https://workbench.developerforce.com/restExplorer.php)

to make a call to retrieve the components included in the deployment. 

When in the Rest Explorer use a Get with a path of 

"/services/data/v49.0/metadata/deployRequest/<DEPLOYMENT_ID>?includeDetails=true"

(replace <DEPLOYMENT_ID> with the id you see in the Deployment Status e.g. Name:0Af1E00009PLDQ)

If you need to connect to the sandbox SFDX

 You can always view all possible connection methods in sfdx sfdx auth --help