#+Time-stamp: <2021-08-02T12:53:08>
This is a minimal working example showing how to automate folder creation via triggers on Account Object creation/update. It does not include technical service account setup.
It is recommended to write a project readme documenting the values used to configure your Q!365 instance.
- Microsoft Azure
- Microsoft 365
- Salesforce
- Salesforce CLI (sfdx)
Install Q!365 in your Salesforce Org and set it up according to the Q!365 Admin Documentation.
Navigate to your workspace folder via CLI, and execute:
sfdx force:project:create -p pkg -n $project
where $project
is the name of the directory for your project
files.
Enter the directory:
cd $project
It is recommended to use git for version control. Initialize a git repository and connect it to github with:
git init
git remote add origin git@github.com:$organization/$project.git
Connect the sfdx Project with your Salesforce Org:
sfdx auth:web:login -a $project -r https://test.salesforce.com
sfdx force:config:set defaultusername=$project
From now on, opening the Salesforce Org via sfdx should work:
sfdx force:org:open
Optionally only generate the login link, for manual copy-pasting:
sfdx force:org:open -r
The Service Account can be configured under Setup
> Home
> Named Credentials
Navigate to Setup
> Home
> Custom Settings
> New
to create a
new Custom Settings object, name it Q365_Project_Settings
.
On this Custom Settings Object, create new Custom Fields of type Text with a length of 255 and the following Field Labels:
- Template Drive -> Document Library for maintaining object templates
- Template Accounts -> Folder Id of the object template
- Destination Drive -> Destination document library
- Destination Root -> Destination parent folder (if none: String ‘root’)
If there’s no parent folder associated to the account automation, set the Destination Root field to the string ‘root’. Otherwise, set it to the corresponding folder Id as shown here.
Populate the Field Labels via the Manage
button on the Object with the
appropriate Ids from GraphExplorer, which will be retrieved in the
next part. Destination Root can be set to the string ‘root’ if there
is no Sharepoint parent folder.
for executing HTTP requests
Make sure to # to your Account, and set permission
Sites.ReadWrite.All
via ...
> Select permissions
Run query:
The Response preview-window should contain the Sharepoint Site Id in the form of:
company.sharepoint.com,some-alphanumerics-with-dashes,some-alphanumerics-with-dashes
Using the Sharepoint Site Id, acquire the Drive Ids with:
Using the Drive Ids, acquire the Templates Id and Destination Root, if applicable:
GET https://graph.microsoft.com/v1.0/drives/{drive-id}/root/children
See the respective files in this repository for code examples.
Download the Custom Object definition:
sfdx force:source:retrieve -m 'CustomObject: Q365_Project_Settings__c'
Create Apex classes for configuration and directory creation:
sfdx force:apex:class:create -d pkg/main/default/classes -n SharepointConfig
sfdx force:apex:class:create -d pkg/main/default/classes -n SharepointUtilities
sfdx force:apex:class:create -d pkg/main/default/classes -n SharepointFoldersCtrl
Create Apex Triggers for the Sharepoint Folders to be used as template structures:
sfdx force:apex:trigger:create -d pkg/main/default/triggers -n SharepointFoldersAccounts
Create a $project/package.xml
file detailing your changes.
Deploy your changes to the org with:
sfdx force:source:deploy -x package.xml [-u $targetorg]
If deployment fails, it does so detailing the errors responsible. Iterate fixing them until deployment succeeds.
If using git for version control, commit your changes.
List all SFDX commands:
sfdx commands
Show help for SFDX command COMMAND:
sfdx help COMMAND
sfdx auth:list
sfdx config:list
sfdx force:org:list