Setup Help - revaturelabs/assignforce-force GitHub Wiki

PREREQUISITES

  • Clean DE org with My Domain set up
    • OR a fresh trailhead playground
  • Dev hub enabled in your org
  • Git installed and configured
  • sfdx installed and configured

For SFDX CLI Users

Script

The easiest way to get the project set up is to run the Setup.exe script provided in the README. It takes 2 command line arguments:

  • Desired name of the folder that will house your git repo
  • Desired alias for the org

This script sets up your git repo, creates an sfdx project, authorizes your org, and deploys the source to it. If you use it, you don't need anything else in this article.

Initialize your git repo

You can set up your git repo in 2 ways.

  1. Clone the repo:
git clone https://github.com/j-colson419/assignforce181210.git
  1. Navigate to the folder that will be the repo and run the 3 commands:
git init  
git remote add origin https://github.com/j-colson419/assignforce181210.git`  
git pull

Adjusting Files

You'll need to remove a few permissions from the admin profile in order to deploy successfully. Don't worry, you don't need them. The admin profile is located at force-app/main/default/profiles/admin.profile-meta.xml, and you need to remove the following permissions:

  • ManagePropositions
  • ManageRecommendationStrategies
  • Packaging2PromoteVersion

There may be more, depending on org types. To remove one, delete the whole xml element:

<userPermissions>  
     <enabled>SOME_BOOLEAN</enabled>`  
     <name>PERMISSION_NAME</name>`  
</userPermissions>

Alternatively, if you're hardcore (and running a Unix terminal), run the following commands from the profiles directory:

sed '/{<userPermissions>/{:a;N;/<\/userPermissions>}/!ba};/<name>\(ManagePropositions\|ManageRecommendationStrategies\|Packaging2PromoteVersion\)<\/name>/d' Admin.profile-meta.xml > tmp.xml  
`mv tmp.xml Admin.profile-meta.xml

If you find you need to remove any other permissions, adjust the first command as so:
sed '/{<userPermissions>/{:a;N;/<\/userPermissions>}/!ba};/<name>PERMISSION_NAME<\/name>/d' Admin.profile-meta.xml > tmp.xml

Setting up SFDX

You'll need to create an SFDX project in order to retrieve or deploy. Run the following command:

echo '{
  "packageDirectories": [
    {
      "path": "force-app",
      "default": true
    }
  ],
  "namespace": "",
  "sfdcLoginUrl": "https://login.salesforce.com",
  "sourceApiVersion": "45.0"
}' > sfdx-project.json

If you're on Windows command prompt, you may need to remove newlines, so do this instead:
echo { "packageDirectories": [ { "path": "force-app", "default": true } ], "namespace": "", "sfdcLoginUrl": "https://login.salesforce.com", "sourceApiVersion": "45.0" } > sfdx-project.json

Next you need to connect to your org:
sfdx force:auth:web:login -d --setdefaultusername --setalias YourDesiredOrgAlias

Deploying to your org

Now we just need to deploy the source to your newly authorized org. Email templates need to go first because reasons.

sfdx force:source:deploy --sourcepath force-app\\main\\default\\email -u YourDesiredOrgAlias
sfdx force:source:deploy -x manifest/package.xml -u YourDesiredOrgAlias

NOTE: the \\ works on Windows environments, but may need to be switched to / on Unix machines. I'm not sure and I don't own a Unix machine to test.

For VSCode Users

Setting up SFDX

Ctrl-Shift-P --> SFDX: Create Project with Manifest
Ctrl-Shift-P --> SFDX: Authorize an Org
Ctrl-Shift-P --> SFDX: Authorize a Dev Hub

Setting up Git

Navigate to the terminal in VS Code

git init
git remote add origin https://github.com/j-colson419/assignforce181210.git
git pull

Checkout your branch

Bottom left --> Select your branch

Adjusting Files

As above, remove Einstein and package permissions from admin profile (force-app/main/default/profiles/admin.profile-meta.xml):

  • ManagePropositions
  • ManageRecommendationStrategies
  • Packaging2PromoteVersion

There may be more, depending on org types. To remove one, delete the whole xml element:

<userPermissions>
     <enabled>SOME_BOOLEAN</enabled>
     <name>PERMISSION_NAME</name>
</userPermissions>

Deploying to your Org

Deploy metadata to the org, email templates first because reasons. Just trust me on this

Right-click 'force-app/main/default/email' --> SFDX: Deploy Source to Org
Right-click 'manifest/package.xml' --> SFDX: Deploy Source in Manifest to Org
⚠️ **GitHub.com Fallback** ⚠️