Setup Metadata Sync
Step 1: Creating a Connected App
To begin, we need a Connected App so that we can sync all of your Salesforce Metadata. In Setup, navigate to Platform Tools -> Apps -> App Manager if you are in lightning. If you are in classic, navigate to Create -> Apps
Click the "New Connected App" at the top right corner if you are in lightning. If you are in classic, click the "New" button in the Connected Apps related list.
When making the Connected App, make sure the following are filled out:
Name: Catalio Sync
Developer Name: Catalog_Tooling_API
Callback URL: [PLACEHOLDER]
Selected OAuth Scopes: Full access, Perform requests on your behalf at any time
We will come back and update the Callback URL after setting up the Auth Provider in the next step.
Step 2: Creating an Auth Provider
The authentication provider is utilized to facilitate the authentication with your Salesforce org.
In Setup, navigate to Settings -> Identity -> Auth. Providers if you are in lightning. If in classic, navigate to Security Controls -> Auth. Providers and click the "New" button in the related list.
When making the Auth. Provider, make sure the following fields are filled out:
URL Suffix: CatalogAuth
Consumer Key: [Paste in the Consumer Key]
Consumer Secret: [Paste in the Consumer Secret]
Default Scopes: full refresh_token offline_access
Leave all other fields blank as shown in the screenshot below and save.
The Callback URL has now been generated and is located under the Salesforce Configuration section. Copy the Callback URL and edit the Connected App we created earlier in Step 1, and paste in the Callback URL under the OAuth section.
Save the Connected App. Salesforce should warn you about waiting a few minutes to allow the settings to take effect and propagate throughout Salesforce's infrastructure.
Step 3: Creating a Named Credential
Next we can setup our Named Credential.
In Setup, navigate to Settings -> Security -> Named Credentials if you are in lightning. If in classic, navigate to Security Controls -> Named Credentials and click the "New" button in the related list.
When making the Named Credential, make sure the following fields are filled out:
Label: Catalog Tooling API
URL: Enter your org's instance URL - this will be the URL for your instance (e.g. na1.salesforce.com), or if you are using My Domain, your fully qualified My Domain domain (e.g. mycompany.my.salesforce.com)
Identity Type: Named Principal
Authentication Protocol: Ouath 2.0
Authentication Provider: CatalogAuth
Scope: full refresh_token offline_access
Generate Authorization Header: Unchecked
Allow Merge Fields in HTTP Header: Unchecked
Allow Merge Fields in HTTP Body: Checked
You will be prompted to log in to your org. After you log in, you will see the connected app authorization screen. Click "Allow".
Allow access to this app. Once complete, you should be redirected back to the Named Credential screen and see that the status is now set to "Authenticated as...."
Step 4: Setup Catalog Sync Apex Job
The last step is to schedule your Apex job.
In Setup, navigate to Platform Tools -> Custom Code -> Apex Class if you are in lightning. If in classic, navigate to Develop -> Apex Jobs and click the "Schedule Apex" button in the related list.
Schedule the job through the UI or through anonymous apex that supports your business model. The example screenshot shows how to schedule the job once a day every day. If you need to schedule more often, you can do that as well.
Setup Catalog Component Page Layouts
To make sure the correct fields show for each Component Record Type, the page layouts need to be assigned.
Head on over to the Catalog Component object, then edit the Page Layout Assignments. When done it should look similiar to the below screenshot.