Skip to content

Formula: ext\appSecret\get function #3483

@traien

Description

@traien

when reading secrets via formula scripts, only the encrypted value of a secret is returned.

The official documentation for Reading in Formula
suggests retrieving the secret using record\attribute, but this only returns the encrypted value, making it impossible to use the actual secret in formula logic or workflow HTTP request payloads.

To Reproduce (MANDATORY, DO NOT REMOVE)
Steps to see the current behavior:

  1. Create an AppSecret record with a known secret value.

  2. Run the following formula in Formula Sandbox:

    $secretValue = null;
    
    $secretId = record\findOne('AppSecret', null, null, 'name', 'SECRET_NAME');
    
    if ($secretId) {
        $secretValue = record\attribute('AppSecret', $secretId, 'value');
    }
    
    output\printLine($secretValue);
  3. Observe that the output is the encrypted value, not the actual secret.

Expected behavior
There should be a way to directly retrieve the decrypted value of a secret. For example:

$actualSecretValue = ext\appSecret\get('SECRET_NAME');
output\printLine($actualSecretValue); // Decrypted value

Screenshots

Image

EspoCRM version
9.2.1

Additional context
Proposed solution: introduce a new formula function:

ext\appSecret\get(secretName)

This would make it much easier to work with secrets in formula scripts and workflows.

➡️ See related Pull Request: #3481

Metadata

Metadata

Assignees

No one assigned

    Labels

    improvementImprovement of existing feature

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions