Skip to content

Latest commit

 

History

History
213 lines (191 loc) · 5.85 KB

Commands.md

File metadata and controls

213 lines (191 loc) · 5.85 KB



Commands and Scripts for Salesforce



Repository with tools, tricks, commands and resources for Salesforce development and administration.



Commands

Salesforce CLI

Título y Descripción Comandos
Retrieve metadata sfdx force:source:retrieve -m CustomObject:CustomObject__c
sfdx force:source:retrieve -m ApexClass:MyApexClass
sfdx force:source:retrieve -m Profile:Admin
Save logs beyond debugs logs
- Enter this command in the VS Code terminal.
- Leave it running while performing the desired actions.
- Save file in root folder and put in the log.txt file all the logs that are produced.
- Also, you can retrieve apex log in VS Code: Ctrl + Shif + P Log: Retrieve Apex Log And Show Analysis.
sfdx force:apex:log:tail --color > log.txt
List ORGs sfdx force:org:list
sf org list
Show ORG alias and value sfdx alias:list
Delete an org sfdx force:org:delete -p -u 'orgName'
Show ORG Description sfdx force:org:display
Unset Alias ORG sfdx alias:unset YourAlias
Create package from source in manifest folder sfdx force source manifest create --source-dir force-app/main/default --output-dir manifest --name=package_source
Create package from org in manifest folder sf project generate manifest --from-org OrgName --output-dir manifest --name=package_org
Retrieve from package.xml sf project retrieve start -o OrgName -x .\Package.xml
Assign Permission Set to user sf org assign permset --perm-set-name PermissionSetName -u OrgName
Create scratch-org sf org create scratch --target-dev-hub DevHubAlias --definition-file config/project-scratch-def.json --set-default --duration-days 30 --no-namespace --alias ScratchOrgAlias
SalesforceTreeAPI sfdx force:data:tree:import
Validate pre-deployment sf project deploy validate --source-dir force-app --test-level RunLocalTests --target-org NombreOrg --verbose | Out-File -FilePath validation.txt
Generate password for scratch-org user sf org generate password --target-org OrgName
See password and user info sf org display user -o userName
No reconoce ORGs
Si no reconoce el valor de la ORG
Logout all orgs
Volver a conectar
sfdx force:org:list
sfdx alias:list
sfdx alias:unset XXXX

GIT

Title & description Commands
Diff branches/commits git --no-pager diff --stat branch1..branch2
See log history git log --graph --oneline --all --decorate

SFDX-Git-Delta

Note

SFDX plugin to generate Incremental Salesforce deployments manifests and artifacts

Repository

sfdx-plugin-source-read

Note

sfdx/sf plugin to read Metadata via CRUD Metadata API

Repo

Scripts

Execute Test in Package on deploy

#!/bin/bash
# ------------------- Variable para especificar el nombre de la org según VS Code
DESTINATION="<nameORG>";

# ------------------- Especificar Package.xml, solo debe contener clases APEX y nomenclatura para Test.
# ------------------- Ej.: <nombreClase>_Test, <nombreClase>Test
FILE_PACKAGE="manifest/Package.xml";

#------------ Variable para montar el comando de ejecucion de clases especificas del Test
APEXTEST_LIST="";

while read line;
	do
		if [[ $line == *'Test'* ]];
		then
			line=${line/"<members>"/""};
			line=${line/"</members>"/","};
			if [[ $line != *'DataTestFactory'* ]];
			then
				APEXTEST_LIST="$APEXTEST_LIST$line";
			fi
		fi
	done < $FILE_PACKAGE
	
APEXTEST_LIST=${APEXTEST_LIST%,};

# ------------------- Imprimimos el comando lanzado en la terminal
echo "sfdx force:source:deploy -x "${FILE_PACKAGE}" -l RunSpecifiedTests -r "${APEXTEST_LIST}" -c -u "${DESTINATION}" --verbose";

# ------------------- Comando sfdx para validar clases Apex ejecutando Test Especificos
sfdx force:source:deploy -x ${FILE_PACKAGE} -l RunSpecifiedTests -r ${APEXTEST_LIST} -c -u ${DESTINATION} --verbose;