diff --git a/command/login.go b/command/login.go
index 59aaf99c..4a96090a 100644
--- a/command/login.go
+++ b/command/login.go
@@ -99,6 +99,7 @@ const (
NetworksEnabled
EnableApexApprovalLockUnlock
PermsetsInFieldCreation
+ EnableLightningPreviewPref
)
var ScratchSettingIds = map[ScratchSetting][]string{
@@ -107,6 +108,7 @@ var ScratchSettingIds = map[ScratchSetting][]string{
NetworksEnabled: {"networksEnabled"},
EnableApexApprovalLockUnlock: {"enableApexApprovalLockUnlock"},
PermsetsInFieldCreation: {"permsetsInFieldCreation"},
+ EnableLightningPreviewPref: {"enableLightningPreviewPref"},
}
type ScratchRelease enumflag.Flag
@@ -225,6 +227,7 @@ Available Settings (deployed after org creation):
networksEnabled - Enable Experience Cloud (Communities)
enableApexApprovalLockUnlock - Allow Apex to lock/unlock approval processes
permsetsInFieldCreation - Allow assigning permission sets during field creation
+ enableLightningPreviewPref - Enable Lightning Experience preview pref
Available Releases:
preview - Create scratch org on the next (preview) release
diff --git a/command/login_test.go b/command/login_test.go
index 345fdbb4..d6d713ec 100644
--- a/command/login_test.go
+++ b/command/login_test.go
@@ -338,6 +338,16 @@ func TestConvertSettingsToStrings_PermsetsInFieldCreation(t *testing.T) {
}
}
+func TestConvertSettingsToStrings_EnableLightningPreviewPref(t *testing.T) {
+ result := convertSettingsToStrings([]ScratchSetting{EnableLightningPreviewPref})
+ if len(result) != 1 {
+ t.Errorf("Expected 1 setting, got %d", len(result))
+ }
+ if result[0] != "enableLightningPreviewPref" {
+ t.Errorf("Expected enableLightningPreviewPref, got %s", result[0])
+ }
+}
+
func TestScratchSettingIds_AllSettingsDefined(t *testing.T) {
expectedSettings := map[string]bool{
"enableEnhancedNotes": true,
@@ -345,6 +355,7 @@ func TestScratchSettingIds_AllSettingsDefined(t *testing.T) {
"networksEnabled": true,
"enableApexApprovalLockUnlock": true,
"permsetsInFieldCreation": true,
+ "enableLightningPreviewPref": true,
}
if len(ScratchSettingIds) != len(expectedSettings) {
diff --git a/docs/force_login_scratch.md b/docs/force_login_scratch.md
index 6f92b6f1..9368b6e5 100644
--- a/docs/force_login_scratch.md
+++ b/docs/force_login_scratch.md
@@ -38,6 +38,7 @@ Available Settings (deployed after org creation):
networksEnabled - Enable Experience Cloud (Communities)
enableApexApprovalLockUnlock - Allow Apex to lock/unlock approval processes
permsetsInFieldCreation - Allow assigning permission sets during field creation
+ enableLightningPreviewPref - Enable Lightning Experience preview pref
Available Releases:
preview - Create scratch org on the next (preview) release
diff --git a/lib/scratch.go b/lib/scratch.go
index 3acc1d01..7f1e5783 100644
--- a/lib/scratch.go
+++ b/lib/scratch.go
@@ -205,6 +205,7 @@ func buildSettingsMetadata(settings []string) ForceMetadataFiles {
// Create settings file for each requested setting
apexSettings := false
userManagementSettings := false
+ lightningExperienceSettings := false
for _, setting := range settings {
switch setting {
@@ -231,6 +232,8 @@ func buildSettingsMetadata(settings []string) ForceMetadataFiles {
apexSettings = true
case "permsetsInFieldCreation":
userManagementSettings = true
+ case "enableLightningPreviewPref":
+ lightningExperienceSettings = true
}
}
@@ -252,6 +255,15 @@ func buildSettingsMetadata(settings []string) ForceMetadataFiles {
files["unpackaged/settings/UserManagement.settings"] = userMgmtBuffer.Bytes()
}
+ if lightningExperienceSettings {
+ var lexBuffer bytes.Buffer
+ lexBuffer.WriteString(`
+
+ true
+`)
+ files["unpackaged/settings/LightningExperience.settings"] = lexBuffer.Bytes()
+ }
+
return files
}
diff --git a/lib/scratch_test.go b/lib/scratch_test.go
index 0ea1954d..9bf65d6a 100644
--- a/lib/scratch_test.go
+++ b/lib/scratch_test.go
@@ -49,6 +49,26 @@ func TestBuildSettingsMetadata_ExcludesUserManagementSettingsWhenUnused(t *testi
}
}
+func TestBuildSettingsMetadata_AddsLightningExperienceSettings(t *testing.T) {
+ files := buildSettingsMetadata([]string{"enableLightningPreviewPref"})
+
+ content, ok := files["unpackaged/settings/LightningExperience.settings"]
+ if !ok {
+ t.Fatalf("LightningExperience.settings not generated")
+ }
+ if !strings.Contains(string(content), "true") {
+ t.Errorf("LightningExperience.settings missing enableLightningPreviewPref preference:\n%s", content)
+ }
+}
+
+func TestBuildSettingsMetadata_ExcludesLightningExperienceSettingsWhenUnused(t *testing.T) {
+ files := buildSettingsMetadata([]string{"enableEnhancedNotes"})
+
+ if _, ok := files["unpackaged/settings/LightningExperience.settings"]; ok {
+ t.Fatalf("LightningExperience.settings should not be generated when not requested")
+ }
+}
+
func TestGetScratchOrg_returns_error_when_SignupUsername_is_nil(t *testing.T) {
f := &Force{}
f.Credentials = &ForceSession{}