Wednesday, 26 October 2022

Deleting Salesforce Debug Logs

 Using SFDX:


COMMAND 1:


sfdx force:data:soql:query -q "SELECT Id FROM ApexLog" -r csv > apexlogs.csv


COMMAND 2:


sfdx force:data:bulk:delete -s ApexLog -f apexlogs.csv


Using Workbench:


Navigate to queries -> SOQL Query:


Select Bulk CSV and Input “Select id from ApexLog” to query Box then click Query.


Then download the CSV file by clicking on “download completed batch results” icon under Batches


Once you have the csv file: Navigate to data->delete. Then select from file, choose the downloaded file and click next.


Select Process records asynchronously via Bulk API and choose Object Type : ApexLog then click Confirm Delete. Done

How to add connected app in 2GP Managed Package?

 1.Create a connected App in Salesforce Instance where we maintain namespace.

2.Create a first-generation Managed package(1GP) and add the connected app.

it's fine if the connected app is the only component in the package.

Always use the same namespace as the 2GP package for the 1GP package.

3.Take note of the version number of the connected app,this number is needed later.

4.Upload the 1GP package to create a package version.

5.Promote the 1GP version to the released state.

6.Promoting the 1GP version allows the connected app to be included in a second-generation managed package.

we don't need to install the 1GP version into an org.

7.Now in our source code navigate to folder 'connectedApps' where we are trying to generate 2GP Package.


create an XML file with <connectedAppName>.connectedApp-meta.xml

and the body of the XML file should be as shown below.


<ConnectedApp xmlns="http://soap.sforce.com/2006/04/metadata">

    <developerName><namespace>__<connected_app_Name></developerName>

    <label>A Connected App</label>

    <version>1.0</version>

</ConnectedApp>


Now generate a 2GP package and promote. Then the connected app is automatically added to your 2GP Package.


The version specified in the source file is the version number of the connected app. Use decimal formatting when specifying the version number. 

The version number must match the version number of the connected app before it was added to the 1GP managed package.


Note:


When you add a connected app to a 1GP package and upload the package, the version number of the connected app is auto-incremented. 

For example, when version 1.0 of a connected app is added to a 1GP package, the package version increments the version number 

of the connected app from 1.0 to 2.0. When creating the source file for your 2GP package, specify the version number of the connected app 

before it was uploaded into a 1GP package, in this case, 1.0.


Reference:


https://developer.salesforce.com/docs/atlas.en-us.224.0.sfdx_dev.meta/sfdx_dev/sfdx_dev_dev2gp_connected_app.htm


Saturday, 15 October 2022

Salesforce : Order of Execution

 System Validation Rules (SVR)

Before-Save RT Flows

Apex Before Triggers

Runs Most SVR Again and all Custom Validation Rules

Duplicate Rules

Save Record but does not Commit.

Apex After Triggers

Assignment Rules

Auto-Response Rules

workflow Rules

Escalation Rules

Process/Autolaunched Flows

After-Save RT Flows

Rollup Summary Fields

Commits All DML Operations to Database

Post-Commit Logic Like Email Send