Skip to content

Commit 57dc29c

Browse files
authored
Merge pull request #2 from tcdahlberg/add-records-to-flow
Adding cci automation steps for Site setup and test data. Thanks Luke! Excited to see this in action.
2 parents 4f19d9e + 2c9c876 commit 57dc29c

9 files changed

Lines changed: 2131 additions & 4 deletions

File tree

.forceignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ force-app/main/default/profiles/Custom%3A Marketing Profile.profile-meta.xml
3434
force-app/main/default/profiles/Custom%3A Sales Profile.profile-meta.xml
3535
force-app/main/default/profiles/Custom%3A Support Profile.profile-meta.xml
3636

37+
force-app/main/default/staticresources/SiteSamples
3738
force-app/main/default/staticresources/SiteSamples.resource-meta.xml
3839

3940
# Things to ignore after a site is created in a scratch org

cumulusci.yml

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,37 @@ project:
1010
source_format: sfdx
1111

1212
tasks:
13+
14+
deploy_site_config:
15+
description: Deploys configuration for Development.
16+
class_path: cumulusci.tasks.salesforce.Deploy
17+
options:
18+
namespace_inject: $project_config.project__package__namespace
19+
path: unpackaged/config/site
20+
unmanaged: True
21+
22+
deploy_site_profile:
23+
description: Deploys configuration for Development.
24+
class_path: cumulusci.tasks.salesforce.Deploy
25+
options:
26+
namespace_inject: $project_config.project__package__namespace
27+
path: unpackaged/config/profile
28+
unmanaged: True
29+
30+
deploy_site_settings:
31+
description: Setup the Custom Settings for the Event Site
32+
class_path: cumulusci.tasks.apex.anon.AnonymousApexTask
33+
options:
34+
path: scripts/configure_event_settings.cls
35+
apex: setSiteURL();
36+
37+
deploy_event_records:
38+
description: Configure sample records for the Event app
39+
class_path: cumulusci.tasks.apex.anon.AnonymousApexTask
40+
options:
41+
path: scripts/configure_event_settings.cls
42+
apex: initializeEventSampleData();
43+
1344
robot:
1445
options:
1546
suites: robot/USTEventsDX/tests
@@ -23,5 +54,19 @@ tasks:
2354

2455
flows:
2556
config_qa:
26-
1.1:
27-
task: deploy_qa_config
57+
steps:
58+
1.1:
59+
task: deploy_qa_config
60+
config_dev:
61+
steps:
62+
3:
63+
task: deploy_event_records
64+
65+
config_site:
66+
steps:
67+
1:
68+
task: deploy_site_config
69+
2:
70+
task: deploy_site_profile
71+
3:
72+
task: deploy_site_settings

docs/install.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
To work on this project in a scratch org:
44

55
1. [Set up CumulusCI](https://cumulusci.readthedocs.io/en/latest/tutorial.html)
6-
2. Run `cci flow run dev_org --org dev` to deploy this project.
7-
3. Run `cci org browser dev` to open the org in your browser.
6+
2. Run `cci flow run dev_org --org <org_name>` to deploy this project.
7+
3. Run `cci org browser <org_name>` to open the org in your browser.

docs/set-up.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
2. Select a subdomain that is available. Since you are spinning up scratch orgs you may want to start incrementing a subdomain on a theme (myevents0001...myevents0002).
77
3. Click "Register My Salesforce Site Domain"
88

9+
## Automate the rest of setup
10+
11+
1. Run `cci flow run config_site --org <org_name>` to automate the rest of the setup steps.
12+
913
## Create a site record
1014

1115
After the subdomain is finished registering create a new site record, by clicking the "New" button next to the site header. Fill in the following data and then click "Save."
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
public static void initializeEventSampleData(){
2+
3+
UST_Event__c testEvent = new UST_Event__c (
4+
Name = 'Test Event',
5+
Event_Name__c = 'Test Event',
6+
Event_Type__c = 'Admissions Event',
7+
Event_Status__c = 'Active',
8+
Start_Date__c = System.Today(),
9+
End_Date__c = System.Today().addDays(7)
10+
);
11+
insert testEvent;
12+
13+
UST_Event_Instance__c testEventInstance = new UST_Event_Instance__c (
14+
Event__c = testEvent.Id,
15+
Active_Status__c = 'Active',
16+
Start_Date_Time__c = System.Today(),
17+
End_Date_Time__c = System.Today().addDays(7)
18+
);
19+
insert testEventInstance;
20+
21+
}
22+
23+
public static void setSiteURL(){
24+
25+
String siteName = 'UST_Events';
26+
27+
Site site = [
28+
SELECT GuestUserId
29+
FROM Site
30+
WHERE Name = :siteName
31+
];
32+
33+
String path = '/sites/servlet.SiteDebugMode';
34+
PageReference pr = new PageReference(path);
35+
pr.getParameters().put('guid', site.GuestUserId);
36+
pr.getParameters().put('sitedebugmode', 'x');
37+
String url = pr.getContent().toString().substringAfter('URL=').substringBefore(path);
38+
39+
UST_Event_Settings__c eventSettings = UST_Event_Settings__c.getOrgDefaults();
40+
eventSettings.Community_Base_URL__c = url;
41+
upsert eventSettings;
42+
43+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
3+
<types>
4+
<members>UST Events Profile</members>
5+
<name>Profile</name>
6+
</types>
7+
<version>44.0</version>
8+
</Package>

0 commit comments

Comments
 (0)