Skip to content

QKom/Q365-Examples-Automation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Automating Q!365 projects - A workflow example

#+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.

Prerequisites

  1. Microsoft Azure
  2. Microsoft 365
  3. Salesforce
  4. Salesforce CLI (sfdx)

Setting Up

Install Q!365 in your Salesforce Org and set it up according to the Q!365 Admin Documentation.

SFDX

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

Automation Workflow

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:

  1. Template Drive -> Document Library for maintaining object templates
  2. Template Accounts -> Folder Id of the object template
  3. Destination Drive -> Destination document library
  4. 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:

GET https://graph.microsoft.com/v1.0/sites?search=

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:

GET https://graph.microsoft.com/v1.0/sites/{site-id}/drives

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

SFDX

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.

Tips

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages