Skip to content

Automated cleaning


Why cleaning sources ?

Salesforce CI/CD Pipelines does not natively work without many manual operations to update the XML... so the deployments passes !

sfdx-hardis provides a set of commands to automate those boring XML updates that can be called every time a user prepares a merge request using command sf hardis:work:save

Here is the list of available automated cleanings, that can also be called manually using command

Example of cleaning config in a .sfdx-hardis.yml config file:

autoCleanTypes:
  - destructivechanges
  - datadotcom
  - minimizeProfiles
  - listViewsMine

Dashboards

Property: dashboards

Removes hardcoded user ids from Dashboards


Destructive Changes

Property: destructivechanges

Any file corresponding to an element existing in manifest/destructiveChanges.xml is deleted.


List Views Mine

Property: listViewsMine

List views with scope Mine can not be deployed.

As a workaround, scope is set back to Everything in XML, but the list view reference is kept in a property listViewsToSetToMine in .sfdx-hardis.yml, and after deployment, manual clicks are simulated to set back their scope to Mine !


Minimize Profiles

Property: minimizeProfiles

It is a bad practice to define on Profiles elements that can be defined on Permission Sets.

Salesforce will deprecate such capability in Spring 26.

Don't wait for that, and use minimizeProfiles cleaning to automatically remove from Profiles any permission that exists on a Permission Set !

The following XML tags are removed automatically:

  • classAccesses
  • customMetadataTypeAccesses
  • externalDataSourceAccesses
  • fieldPermissions
  • objectPermissions
  • pageAccesses
  • userPermissions (except on Admin Profile)

You can override this list by defining a property minimizeProfilesNodesToRemove in your .sfdx-hardis.yml config file.

__

System.debug

Property: systemDebug

System.debug are useless, as explained in this article

Comments automatically all System.debug in the code to enhance performances.


Named metadatas

Cleaning can remove files related to named elements.

Case Entitlement

Property: caseentitlement

Removes all Case Entitlement related fields, like Case.EntitlementId and Case.MilestoneStatus

DataDotCom

Property: datadotcom

Removes all Case Data.com related fields, like Account.DandbCompanyId and Account.Jigsaw

Local Field

Property: localfields

Removes all Local fields, like Account.NameLocal and Lead.CompanyLocal

Product Request

Property: productrequest

Removes all Local fields, like ProductRequest.ShipToAddress and ProductRequest.ShipmentType