Placeholders and variables

You can use placeholders in your script to reference the target asset and the current user. To add placeholders, enter an opening bracket ([) and select a placeholder from the list.

Asset information

Most asset placeholders use the format Document.[Field name]. Some of the most common placeholders for the Core fields of a target asset include:

  • Document.Title
  • Document.CaptionLong (the Description field)
  • Document.Copyright
  • Document.FileCreateDate
  • Document.FileEditDate
  • Document.FileImportDate
  • Document.FileSize
  • Document.EmbargoDate (the Embargo Date field)
  • Document.Identifier (the unique ID)
  • Document.Purpose (the Visibility Class)
  • Document.IIIFResourceType (the IIIF Resource Type field)
  • Document.Lockdown (Assets in lockdown cannot be shared, and all existing shares are revoked.)
  • Document.OriginalFileName
  • Document.WorkflowStatus
  • Document.DocSubType (the asset subtype)

Additional asset information placeholders you might find useful include:

  • Document.TitleWithFallback (the assets title or, if there is none, the asset’s original file name)
  • Document.Embargo (a boolean value indicating whether the asset is under embargo)
  • Document.Keywords (the asset’s tags)
  • Document.RecordID (the asset’s Record ID)
  • Document.EditDate (the Last Modified date)
📙

Feature documentation

Orange Logic users with a Link account can go to the following articles to learn more about these topics:

User information

Some of the most common placeholders for user information are listed below. These placeholders pull information from the account of the user who triggered the automation.

For example, when a user clicks a button or saves an asset to trigger an automation, the Sender.CoreField.First_Name placeholder pulls in the value of the First name field in the user’s contact record.

  • Sender.CoreField.First_Name
  • Sender.CoreField.Last_Name
  • Sender.CoreField.OrganisationName
  • Sender.CoreField.Contact_type (the type of account, such as Staff, Source, etc.)
  • Sender.CoreField.Department
  • Sender.CoreField.DisplayName
  • Sender.CoreField.Identifier
  • Sender.CoreField.LoginID
  • Sender.CoreField.MustResetPassword
  • Sender.CoreField.CreateDate
  • Sender.CoreField.EditDate
  • Sender.CoreField.EditLocation
  • Sender.RecordID (the encrypted ID of the user’s account)
📙

Feature documentation

Orange Logic users with a Link account can go to the following articles to learn more about these topics:

Workflow variables

You can use the Workflow Design Tool to create workflows that automate tasks, manage project and asset life cycles, and build custom integrations. When building workflows, you can create variables to pass values from one workflow element to another and create conditional paths. Variables can be set on all workflow elements (triggers, actions, statuses, decisions, etc.). When you write a script in the development environment, you can reference any variable that was created in that workflow.

Notes

  • Only calls made with Utils.ExecuteHttpRequest or Utils.CallInternalAPI set the status code.
  • The status code is not available when the workflow runs asynchronously, because the action finishes before the script runs. Set up the automation to run synchronously when a later step needs the status code.
  • The HTTPStatusCode variable is available beginning in Orange Logic Saigon.

Example: Create a decision based on an integration’s response status

Suppose you want to send product assets to a product information system (PIM) when the Visibility Class is approved. You can build an automation that fires when the Visibility Class is updated, and you can build a script with the Run script action to push the assets to the PIM. The API returns an HTTP status code indicating whether the asset was successfully received. You can capture that status code as a variable and use it to route the workflow based on the outcome.

  1. Add the Run script action to a workflow and build a script to send records and metadata to the third-party system.

  2. Set a variable on the Run script action’s HTTP status code.

  3. Add a decision after the Run script action.

  4. Configure transitions on the decision:

    1. Success (If): Edit the if transition and add a requirement stipulating that the status code variable is equal to the success code the outside system returns, such as "200." Some services return 201 or 204 on success, so check the service's documentation.
    2. Expired credential: Add a transition with a requirement stipulating that the status code variable is equal to "401."
    3. Error (Else): You don’t need to edit the else transition. If the response status code is else, such as 404, 500, or 0, the workflow follows the error path.

    Condition based on the integration variable that must be met for the workflow to follow the "success" path

  1. Add the appropriate actions to each transition. For example, you might add the Edit field values action to the success path to note that the asset was sent to the PIM. You might also add the Send email action to the Error path to alert the operations team.

    Workflow with a decision path determined by the HTTP status code from a custom integration

The status code variable receives a value depending on the following scenarios:

  • One call in the script: The status code of that call.
  • Several calls in the script: The status code of the last call that completed. To return a different code, the script sets ScriptResult.StatusCode at the end. To learn how, go to Return a result with ScriptResult in the developer documentation.
  • No response: The response is 0 when the outside system doesn't respond, such as on a timeout, or when the script doesn’t make a call.
💡

Tip

By default, decisions have two transitions: if and else. You must set requirements on the if transition, and you cannot add requirements to the else transition. However, you can add transitions by clicking the plus sign next to transitions. You must configure the requirements on new transitions. To try a call again after a 429 (too many requests) response, add a transition for the 429 status code that leads back to the Run script action. The action runs again. A workflow fails when the same action runs too many times in one loop, so use this pattern only for occasional rate limits.

Add workflow variables to a script

To add a workflow variable to your script, enter an opening bracket inside single or double quotation marks ( “[“ ) and type "Variable" to list that workflow’s existing variables. Select a variable to add it to your script.

Alternatively, you can type [Variables.variable name] to add the variable. Variable names are case insensitive and can include spaces.

Add a workflow variable to a “Call external API” script

Add a workflow variable to a script

Create variables from the response

When writing the script, configure the sample response in the bottom window as a JSON object. Then, use the Utils.SetScriptOutput function to set the response in the script template.

You can designate the script’s response as a workflow variable with this syntax: var response =. When you add the response as a variable in the script, the variable will appear in the Workflow Design Tool interface, so you can reference it in later workflow steps if needed.

Custom script settings that designate a response as a workflow variable

After the script sets a response, the Workflow Design Tool lists its fields under Current node output in the action’s Set variables menu. Select a response field there to create a workflow variable from it, then reference that variable in a later workflow step.

Set the script’s response as a variable in the Run script action settings in the Workflow Design Tool

The sample below imports an asset and its metadata to the Orange Logic platform. The asset’s title is “Product photo,” and its description is the AI agent’s confidence score, which is a variable pulled from the workflow. The response is configured to list the asset’s title and the success status. The response will be available as a variable in the Workflow Design Tool, so you can build a conditional path based on the response value. For example, if the response is anything other than successful, you might want to notify a team to review the asset.

Utils.ImportFromThirdParty(
    {
        DownloadURL: 'https://mangovations.orangelogic.com/AssetLink/4ry6b3133j753w1a03nh3t8jpwspyx17.JPG'
	FolderID: '2Y8TWAFUPL3'
	SingleValueMetadata: { "Title": "Product photo", "Description": "[Variables.Agent confidence score]" }
    },
    // Success callback function
    function (_sResp) {
        var oResp = JSON.parse(_sResp);

        Utils.SetScriptOutput(oResp);

        Log.Warn('Executed successfully: ' + _sResp);
    };
//Failure callback function
function (_sResp) {
    Log.Warn('Execution failed: ' + _sResp);
}
)
ℹ️

Note

Orange Logic users with a Link account can go to the Workflow variables article to learn more.


Did this page help you?