This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Azure DevOps / Powershell example | |
$priorVersionNumber = $args[0] #Assumption: you have the version number the prior deployment to this environment was tagged with | |
$newVersionNumber = $args[1] #Assumption: you have the new version number to tag the new commit with | |
$environment = $args[2] #Assumption: you have the name of the environment you are deploying to | |
$releaseCommit = $args[3] #Assumption: you have the id of the commit you are deploying | |
Invoke-Expression "git checkout $releaseCommit" | |
#Use the SFDX Git Delta plugin to deploy the delta between the checked out release commit and the tag last deployed to the current environment | |
#https://www.npmjs.com/package/sfdx-git-delta |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Loop through all .apex scripts in the directory passed to $args[0] and execute them in sequence | |
$path = $args[0] | |
Get-ChildItem $path -Filter *.apex | | |
Foreach-Object { | |
# $_ : object in loop | |
# $_.FullName: full path to file, including extension | |
# $fileName: filename and extension without path | |
$fileName = Split-Path -Path $_.FullName -Leaf -Resolve | |
sfdx force:apex:execute -f "$path\$fileName" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public with sharing class ProductionCode.cls { | |
... | |
private static void scheduleBatchExecution(){ | |
... | |
//Use in place of DateTime.now() | |
DateTime nowDT = Utilities.getCurrentDateTime(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static set<string> getCreatableFields(Schema.SObjectType objectType) | |
{ | |
Map<String, Schema.SObjectField> fMap = objectType.getDescribe().Fields.getMap(); | |
set<string> creatableFields = new set<string>(); | |
if (fMap != null){ | |
for (Schema.SObjectField ft : fMap.values()){ // loop through all field tokens (ft) | |
Schema.DescribeFieldResult fd = ft.getDescribe(); // describe each field (fd) | |
if (fd.isUpdateable()&&!fd.isUnique()){ // field is creatable | |
creatableFields.add(fd.getName()); |