-
Notifications
You must be signed in to change notification settings - Fork 790
Description
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:
-
Create an
AppSecretrecord with a known secret value. -
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);
-
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 valueScreenshots
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