Configuration Guide

Snowflake Connection

Ensure that package installation and initial Snowflake configuration has been performed.

Lightning components configuration

Here's how to configure the individual Lightning components within Salesforce.

Add the Lightning Component to the Page

Navigate to a Record page or Home page. Click the cog icon, then "Edit page":

Edit a record page

Under the "Custom" Components section, drag the "Snowflake List Component" onto the record page.

Set the Snowflake Connection Name field to match the name of the Snowflake connection configured previously.

Configure Pre-Snowflake SOQL queries (Optional)

Optionally, enter one or more pre-Snowflake SOQL Queries to execute on the Salesforce platform, delimited by the ';' character. The results of these queries can be used to filter the main Snowflake query. For example, the following query will fetch the Accounts for the current user:

select AccountNumber,Name from Account where OwnerId = $CurrentUser.Id and AccountNumber != null

There are two ways to insert contextual data into these query: 1) If the Page is a record page (e.g. Assets), you can use the notation {$CurrentRecord.FieldName}, e.g. {$CurrentRecord.AccountNumber} 2) To access attributes from the current user, you can use the notation {$CurrentUser.FieldName}, e.g. {$CurrentUser.Id} (as shown above)

Configure the Snowflake query

Paste in the query to be submitted to Snowflake. Use a SELECT, FROM, and WHERE clause, but do not add ORDER or LIMIT clauses - these will be appended automatically by the component based on user interaction.

Contextual data ($CurrentRecord and $CurrentUser) is supported as described above, as well as results from the pre-Snowflake SOQL Queries (e.g. $Query1.Name). You can use SnowflakeField=${Query1.Field} for a single record, or SnowflakeField IN ({$Query1.Field}) for multiple records.

As a complete example, the following query uses the pre-Snowflake SOQL query from the previous section to show the Accounts owned by the current user that have the greatest recent transaction volume:

select ACCOUNT_NUMBER as "Account Number", 
       sum(TRANSACTION_AMOUNT) as "Transactions Sum", 
       count(TRANSACTION_AMOUNT) as "Transactions Count" 
from PRESCRIPTION_FULFILLMENT
where TRANSACTION_DATETIME > dateadd(days,90,current_date) 
      and ACCOUNT_NUMBER in ({$Query1.AccountNumber})
group by ACCOUNT_NUMBER

This renders as:

Add component and configure

Adding Icons to columns (Optional)

To make an icon appear in the list view, simply add an additional column in the Snowflake query, with the same name as the original column and _ICONTYPE appended.

The value of this field must match an iconName as described in the lighting:icon documentation. The value can be fixed for all results (e.g. to link to a record type), or dynamic based on the each row (e.g. showing up/down trend arrows, or happy/sad sentiment).

As an example, if we modify our above query to:

select ACCOUNT_NUMBER as "Account Number", 
       'standard:account' as "Account Number_ICONTYPE",
       sum(TRANSACTION_AMOUNT) as "Transactions Sum", 
       count(TRANSACTION_AMOUNT) as "Transactions Count" 
from PRESCRIPTION_FULFILLMENT
where TRANSACTION_DATETIME > dateadd(days,90,current_date) 
      and ACCOUNT_NUMBER in ({$Query1.AccountNumber})
group by ACCOUNT_NUMBER

We see the account icon in the "Account Number" column: With icon

The "Post-Snowflake substitutions" field allows blending of initial SOQL query results back into the Snowflake results. Optionally, a hyperlink can be added to allow the user to navigate to a record of interest from the table.

For example, if we set the field to:

Account Number=$Query1.AccountNumber:Name!Link

This means: For the "Account Number" column in the Snowflake results, find its value in the AccountNumber column of the first SOQL Query results, and replace it with the value in the Name column of the same record. Additionally, create a hyperlink to the matching record:

With hyperlink

Now, the name of the account is visible in the table even though only the AccountNumber is in Snowflake. The user can click on the hyperlink and the Account will open.

Save and Activate

Once the data is rendering as expected in the preview, you can save the page and click Activate to assign the layout.

Adding a text element to a Record Page

Add the Lightning Component to the Page

Navigate to a Record page, which has at least one field containing data that can be used to link to Snowflake data. Click the cog icon, then "Edit page":

Edit a record page

Under the "Custom" Components section, drag the "Snowflake Text Component" onto the record page.

Set the Snowflake Connection Name field to match the name of the Snowflake connection configured previously.

Configure the Snowflake Query

Paste in the query to be submitted to Snowflake. The query must return a single record, and the first column will be added to the page as text. Use a SELECT, FROM, and WHERE clause, but do not add ORDER or LIMIT clauses - these will be appended automatically by the component based on user interaction. To automatically substitute values from the current Salesforce record, use the notation {$CurrentRecord.FieldName} (e.g. {$CurrentRecord.CustomerNumber}).

As a complete example, imagine you have a Snowflake table containing Solar array production linked to Assets via serial number. You could add a Snowflake Text Component to the Salesforce "Array" page with a query like: select max(PRODUCTION_DATE) from SOLAR_PRODUCTION where ARRAY_SERIAL_NUMBER={$CurrentRecord.SerialNumber}

Text Component Basic

Setting the font size and color

The query may also contain values for FONT_COLOR and/or FONT_SIZE, which are passed to the component.

An example would be 'data freshness' shown in green or red, depending on the age of the most recent data:

select datediff(day,max(PRODUCTION_DATE),current_date) || ' day(s)', iff(datediff(day,max(PRODUCTION_DATE),current_date)<2,'green','red') as FONT_COLOR from SOLAR_PRODUCTION where ARRAY_SERIAL_NUMBER={CurrentRecord.SerialNumber}

Text Component Advanced

Save and Activate

Once the data is rendering as expected in the preview, you can save the page and click Activate to assign the layout.