Skip to main content

Profiles

Profiles in Superblocks make it easy to manage and customize credentials and variables for different development environments, like Production, Staging, or Development, as well as different regions within those environments, like us-east vs us-west.

  • Use Development configurations in Superblocks Edit modes, Staging data sources to review and test changes, and Production once Applications, Workflows, and Scheduled Jobs are deployed.
  • Add multiple Production Instances (ex: us-east, us-west, eu-west, etc) to your Application’s deployed mode. Let users switch between Profiles to fetch region specific data.

Manage organization profiles

Your Superblocks account comes with two built in profiles, Staging and Production.

Admins can create new profiles to represent the stages in your company’s software development lifecycle. To add a profile:

  1. Navigate to the Profiles page under Organization Settings
  2. Click Add Profile
  3. Provide a unique name for your profile and optional description
  4. Click Create
default production and staging profiles
create a new profile
info

Each profile has a unique alphanumeric key associated with it. Use the key when referencing the profile directly. The key can’t be changed once you’ve created the profile to prevent references from breaking.

Once you’ve created a new profile, you can start:

Configuring integration credentials

In Superblocks, integrations can have many configurations to help connect to different database instances or API servers. Each configuration can then be linked to one or more profiles. Configurations define the set of credentials used when an API, Workflow, or Scheduled Job executes against a profile (e.g., when executing a Workflow against staging).

To update the configuration associated with a profile:

  1. Navigate to Integrations and search for your integration or create a new one
  2. Upon creation, the integration has only a Default configuration that applies to all profiles. Click the ➕ icon to "Add new configuration" and select the profile(s) that will be used for this configuration
  3. Fill out the configuration form with values specific to the selected profiles
  4. Click Test Connection to check that Superblocks can connect to the data source
  5. Once you’ve successfully connected, Create or Save changes to your integration's configurations
configure integration for a profile

Using profiles

With your integrations configured to connect to databases and APIs in different environments, you can now start building Apps, Workflows, and Scheduled Jobs to leverage these different configurations.

Add profiles to Edit, Preview, or Deployed modes

Profiles can be added or removed from the Edit, Preview, or Deployed mode of your Apps, Workflows, and Scheduled Jobs from the Profile Settings menu. Access the menu from the Settings icon on the lower left corner of any App, Workflow, or Scheduled Job then click Profiles.

To make additional profiles available in each mode:

  1. Click the ➕ icon next to the profiles for the desired mode
  2. Choose the profile to add to the mode
configure available profiles for each mode

To remove a profile, click the trash can icon.

info

Since Scheduled Jobs cannot be invoked by end-users, you only need to choose which profile to use in Edit and Deployed modes. The Edit mode Profile will be used when running the job interactively while the Deployed mode Profile will be used when the job runs on its schedule.

Change the default profile

When multiple profiles are available in Edit, Preview, or Deployed mode, you can set a default profile for the mode. This is the profile that will be used to execute APIs when the Application first loads, or when Workflows are called without a profile specified.

To change the default profile, select the radio button next to the profile you want to use by default when APIs run:

configure available profiles for each mode

Change the current profile from the Application UI

When multiple profiles are available in an Application, you can let users change the current profile using the Set Profile action.

set profile action type

Use this action to change the selected profile:

  • When a user selects a new profile from a Dropdown
  • When changing between Tabs in your application
  • Before running a particular API that is triggered on a Button click

For example, let's say we're building an Application that shows orders made by European, US, and Japanese customers. There are separate Orders databases in each region that we'll query to get customer orders to show to our Support Agents. To support this, we’ve created separate profiles for our Europe, United States, and Japan regions. To let our Support agents change between regional data centers, we’ve added a Dropdown to the Application listing all the available profiles.

set profile action type

Since only Staging is available in Edit and Preview modes, the dropdown will only show Staging in these modes. When the Application is deployed though, the three Production profiles, Europe, Japan, and United States will be shown to users.

When the user selects their desired region from the dropdown, that profile is activated and the getOrders API is re-run, fetching data from that region’s databases.

info

If you would like to replicate this feature in your application, we have created a guide here as a starting point.

Reference profiles in code

Profiles can be referenced in code using {{Global.profiles}}. The profiles object has the following attributes available:

AttributeDescription
{{Global.profiles.available}}Returns the full list of profiles defined in Profile Settings for the current mode of your App, Workflow, or Scheduled Job.
Ex: When viewing your deployed Application, this will only list the profiles set up for the Deployed mode.
{{Global.profiles.default}}Returns the default profile for the current mode of your App, Workflow, or Scheduled Job.
{{Global.profiles.selected}}Gives you the currently selected profile that will be used when executing APIs. This value will change when calling the Set Profile action.

Use cases

Change profile with a URL query parameter

Before Profiles were released, users could control the environment via an environment query parameter in the Application URL. This is no longer built into Superblocks, but can be implemented with the following:

  1. Add a backend API with a single JavaScript step that evaluates the query parameter.

    if (Global.URL.queryParams.environment) {
    return Global.profiles.available.filter(item => item.key == Global.URL.queryParams.environment)[0].id;
    } else {
    return Global.profiles.selected.id
    }
  2. Configure the API to always run on page load.

  3. Configure the API response onSuccess handler to Set Profile to the Profile returned by the API, and run any APIs that depend on the Profile.

    set profile from url query parameter
  4. Set dependent APIs to never run on page load.

Restrict profiles based on user group

If certain users should only have access to a subset of environments, users can restrict which profiles are available in their UI. Example if using a Dropdown:

restrict profiles available in a dropdown based on user group
{{Global.profiles.available.filter(item => {
if (Global.mode == 'EDIT' || Global.user.groups.map(item => item.name).includes("Engineering")) {
return true;
} else if (item.displayName.startsWith('Prod')) {
return true;
}
})}}