Setting up a Salesforce Communities/Experience Cloud site for Scratch Orgs

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this video I'll show you how to set up a community or a digital experience site or use with scratch orgs and Salesforce so what we have here is an sfdx and empty sfdx project that has already been authorized to access a Dev Hub so in this case it's developer org that I have enabled the dev Hub functionality and the first step is to modify the project scratchdef.json so this is the file that determines what features are turned on in scratch orgs that we create so in this case we need to make sure the addition is set to Enterprise and that's because the Enterprise license will give us a guest user license that the community or the experience Cloud site whichever vocabulary you use needs in order to function so along with the addition we have to add the community feature and we have to add a couple of settings that go along with that and we're going to say community settings and the first setting we need is enable networks enabled foreign and one more setting we also need experience bundle settings and we need to set we need Mabel experience bundle metadata you just turn that on the use the experience Cloud bundling mechanism okay so effectively changing this Json file means that when we create scratch orgs they will already have the digital experience setting enabled so we can then deploy our our source code that has the digital experience that or the community to directly to that that org without having to go in and flip anything in setup so it's pretty convenient okay so now that's created let's go to our Command palette Ctrl shift p and create a default scratch org and we're going to use that Json file we just modified and we will call this a source org because this is the scratch org that we're going to use to build our initial site that will then pull down so we'll call this the source org and I'll set this to expire after one day okay now that we have a scratch already created we will open that org and go through the UI and create our the actual experience site so let's go to open default org and here we are into the scratch org we're going to go to setup and in the search bar and setup I usually type all Sites all sites and if we hadn't changed our scratch or config file this wouldn't be available we'd have to go through setup and turn it on so we'll click on all Sites and we'll create a new site in this case we're going to use the customer service template the aura template but the instructions for all this should work the same with the lwr sites select customer service because it's a very popular template and we'll say get started now for the name we want to avoid using spaces in the name so really a one word name and if you need two words put an underscore between the two words spaces the UI will take it but later when you're doing the push and the pull it'll get very angry Visual Studio code or the Salesforce CLI won't like that there's spaces in the file names and things like that so make sure everything is one continuous word no spaces so in this case we're just going to call this demo and I'll add it to the URL just for completeness and we'll create in this section will take just a second okay so the site's been created now the first thing to note is let's go to the Builder and look at the the default home page of the template and one thing to note when you first create this site you want to make a change to the site so that when we pull it down if you for some reason if you don't change something on the site when you first do your first pull it won't pull all the files that Define the site and I'm not really sure why but it is the case so what we're going to do is I'm going to change the title from welcome to hello world which is more you know for computer science software development that's more correct for your initial your initial title anyway okay I'll say this is a a demo site for demonstrating use with scratch hello if I can spell scratch scratch orgs so now that we've made that change the next thing that's interesting is if we go back to the uh to the administration section the email templates are a problem so when we do the poll the there are four email templates that are attached to this uh this template and the poll will not pull down the default email templates so we're gonna have to do is go into the classic email templates and clone these four email templates that are assigned here and then come back to this administrator page and assign the Clone templates to the website so that when we pull them down the Clone templates come down so it's a little a little quirky but bear with me so those are the four email templates and what we're going to do is go back to to our setup and we're going to go to the classic email templates because the lightning email templates don't work for this as far as I know classic email templates and the 4r change password so this is one of them we're going to clone this one and I will rename this demo to differentiate it from the existing template we'll save that find our next one which is the uh let's see forgot password email clone this change the name save that two down two to go we also need the new member welcome email clone that a name save that one more we also need the Headless reset password email clone that and rename foreign so now that we've saved that let's go back to the administration section of our site and set these email templates to our clone versions so actually let me look forgot password so I need the forgot password that one there I need the change password email that one there scroll down oh I could have sworn the welcome email was oh here it is sorry hey I missed it there it is welcome emo is there new member welcome email is at the top and last but not least the Headless forgot password email which is right here so let's save that okay so after that we've covered all our bases in creating the experience site or the community in the UI so let's go back to our Visual Studio code which is now pointing to that Source org and let's go to the command palette and pull the source files down so pull Source from default scratch org okay now you can see that we have the files that represent our website so if we go to experiences I've got all these Pages or all these files if I go down to the home page on the views there's a Json file that represents the home page view and you can see that the text that we changed shows up in here so this is the Json that represents the site or the this collection of files represent the site we just created in the UI so all of that is great so now that we have those files we should be able to test this and prove that this works by creating another scratch organ deploying to that org so if we go up to our Command palette and create a default scratch org using our same Json file and we're going to say target.org it's the target of our deployment decided to expire after one day and let that run for just a second okay so now we have another org that doesn't yet have the the site but it does have the digital experience enabled setting turned on we should be able to push our source to that new org so if we say push source to default scratch org now this will actually fail because there's one more step that I haven't done yet but I want to show you the error first and then show you the solution to the error so you know why you're doing it I would have done that for some of the other things that you need to do in the UI to pull down first but it would be much the video would be too long if I did it that way so in this case it's pretty easy to demonstrate the error and the solution so That's How we'll do it okay failed to run I've got one problem and that problem is there's an error in the app switcher meta so really we just need to ignore this file so if you're familiar with Git there's a git ignore file so you have files that you ignore you have git ignore so that you don't end up pushing changes to that file or committing changes to that file it's just something you want get to ignore well Salesforce has the same thing it's called the force ignore so we need to add the app switcher file this one that's this default file that it won't push up but we're just using the default anyway in the org so we don't need to to maintain changes with this so what we're going to do is we're going to add this file to our Force ignore the app switcher and specifically we just want this one file so app switcher dot app menu Dash meta dot XML just like it says right here we're just adding that file so if I save that let me go back to our Command palette and we push again now the kind of the the mechanism is ignoring that file the Salesforce CLI is ignoring that file in the push commands and it'll ignore that file in the pull command as well or ignore that file in the pull commands okay so now we've pushed the site to our new org or our Target org so if we go open since the target org is now our default we can say open default org and we can go see that our let's close other tabs just to not confuse ourselves we can see that the site is now available in the Target org as well oops notifications moved on me so we gotta set up and go to all Sites and there's our demo site I go to Builder we should see the modified text on the home view the home page and there it is hello world so we have a digital experience site that we can deploy to scratch orgs or for that matter we can deploy this to any kind of org really and then the nice thing is we have it in file form so now that we have pulled it down and tested it we can push it to GitHub so what I'm going to do is I'm going to go to Source control here I'm going to say publish to GitHub and I'll just leave it called demo site and we're going to make this a public repository on my GitHub account and Okay so let's not include some of these files here the rest of those look good we don't want the SF or the sfdx folders so we'll say okay and it's going to publish the branch all in one shot let's go look at that on GitHub and there we are we have the site published on GitHub uh you can go clone this site as an example for your own digital experience sites and I'll put the link to this uh repository in the description of the video as always thank you for watching
Info
Channel: Mitch Routt
Views: 502
Rating: undefined out of 5
Keywords: Communities, Experience Cloud, Premiere_Elements_2023, SFDX, Salesforce, Scratch Orgs, VSCode
Id: i5BAwoQLZyM
Channel Id: undefined
Length: 16min 13sec (973 seconds)
Published: Fri Mar 24 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.