Thursday 18 April 2024

Salesforce Import and export Files/Attachments

 Salesforce Import and export Files/Attachments


Step 1:  Export files using the below path:  Setup ==> Data ==> Data Export

Select options: 

        Export File Encoding: UTF-8

        Include images, documents, and attachments: Checked

        Include Salesforce Files and Salesforce CRM Content document versions: Checked

        Replace carriage returns with spaces: Checked

 Select Specific objects to get their attachments: Here, I opted Account






Step 2: Download the zip file from Salesforce

Salesforce sends an email once the files are ready to download

 



Step 3: Unzip the downloaded file and navigate to the ContentVersion folder 
             and ContentVersion.csv. add the extension (.pdf, .xlsx, .jpeg, etc.) to any file.

 

Step 4: Create a CSV file with below Header values: 




Step 5: Go to Data loader settings and check both (Read/Write) UTF-8 settings as below:




Step 6: Select the Insert option, search for the content version object, and load the CSV file to upload the attachment.: 



Step 6: Once Upload is completed, Data Loader creates success and error files respectively:


        















Monday 18 March 2024

Salesforce Code Analyzer Command


Salesforce Code Analyzer Command example/Sample


Installing Salesforce code analyzer:

Link: https://forcedotcom.github.io/sfdx-scanner/en/
v3.x/getting-started/install/

Go to VScode -- > New terminal - -> Enter below command
(It installs analyser)
Project location > sfdx plugins:install @salesforce/sfdx-scanner

To check whether the code analyzer is installed or not:

(It checks whether the code analyzer is installed or not)
Project location > sfdx plugins -->

To generate a report Go: to the command prompt

and enter the below command :

(Can generate different reports like .xml, and .csv as well)
Project location > sfdx scanner:run --target "**/default/**"
--outfile results.html


GENERIC COMMAND for Code Scanner

$sfdx scanner:run --target './force-app/main/default/' --projectdir
'./force-app/main/default' --format csv --outfile=codereviewGeneric.csv

CPD Command
$sfdx scanner:run --engine cpd --target './force-app/main/default/'
--projectdir './force-app/main/default' --format csv --outfile=codereviewCPD.csv

DFA Command - Graph Engine (this one takes time to generate report)
$sfdx scanner:run:dfa --target './force-app/main/default/' --projectdir
'./force-app/main/default' --format csv --outfile=codereviewDFA.csv 




reference from : 

https://developer.salesforce.com/docs/platform/salesforce-code-analyzer/guide/dfa.html

https://developer.salesforce.com/docs/platform/salesforce-code-analyzer/guide/cpd-engine.html


Salesforce Code Analyzer Command example/Sample

Wednesday 31 January 2024

Get sObject Name and Permission Set Assignment SOQL in the Salesforce

 Salesforce: Get sObject Name and Permission Set Assignment


SOQL:
SELECT Parent.Name, Parent.PermissionsTransferAnyLead,SobjectType ,PermissionsRead, PermissionsCreate,PermissionsDelete, PermissionsModifyAllRecords, PermissionsViewAllRecords
FROM ObjectPermissions     
WHERE  ParentId in (
            SELECT id
            FROM PermissionSet
            WHERE name IN ( 'Master_Edit_Access'))