---
title: Script Test Use Case
slug: script-test-use-case
docTags: 
createdAt: 2025-08-11T11:13:49.000Z
---

## Scenario: Test Script Action

Rowan is an orchestrator who wants to map static and playbook property data to the Script native action inputs so that he can reference this data in the Python script and test the inputs to see the results before continuing to build the playbook. He also wants to see if there are any discovered outputs in addition to the original outputs.

First, Rowan adds his webhook trigger, so the webhook property data is available downstream in the playbook. Let's see how he sets up the Script native action to see if there are [Discovered Outputs and Testing](https://docs.swimlane.com/discovered-outputs-and-testing).

### Steps to Configure the Script Native Action:

1. Click the **Action** drop-down menu, select **Script**, and enter a title for the action.
2. Click **Configure** to open the Script configuration window. This window displays three tabs: **Script**, **Outputs**, and **Test**.
   **Note:** To ensure proper testing, verify that your script has valid inputs and a valid output structure. This avoids errors in the next steps.
3. From the Script tab, click **Add property** and select **String**. Enter the value "**hello**" for this property.
   **Tip:** You can add multiple input types (e.g., strings, numbers, objects) to test various scenarios.
4. Add another property of type **Object**. Rename the properties as **string\_test** and **object\_test1** for easier identification.
   Inside the **Object** property, click **Add property** again and select **String**. Name this inner string property **string\_2**.
5. In the **Script** pane, enter the script:
6. Navigate to the **Test** tab. This allows you to test the script before finalizing the action.
7. If there are any [discovered outputs](https://docs.swimlane.com/discovered-outputs-and-testing) (outputs automatically generated but not initially visible), click the checkbox next to the discovered outputs to include them for downstream actions.
   **Important:** Discovered outputs can be added for further use in the playbook. Review discovered outputs thoroughly to avoid missing important properties.

## Advanced Script Usage

Rowan also wants to know how to handle complex data or troubleshoot script errors in the process. Here’s how he can handle more advanced use cases.

### Error Handling

- Always validate the input data using conditional statements. For example, check if a required field exists before processing it:

:::BlockQuote
if "required\_field" in action\_inputs: process\_data = action\_inputs\["required\_field"] else: process\_data = "default\_value"
:::

- Handle exceptions within the script to ensure smooth playbook execution:

:::BlockQuote
try: result = complex\_calculation(action\_inputs) except Exception as e: result = f"Error: \{str(e)}"
:::

### Script Flexibility

The script can support complex Python logic, including loops, conditionals, and data transformation functions. Rowan can use these features to build more advanced scripts:

- Example: Loop through an array of objects:

:::BlockQuote
for item in action\_inputs.get("object\_test1", \[]): print(item\["string\_2"])
:::

- Example: Perform a transformation on string data:

:::BlockQuote
action\_outputs\["upper\_case\_string"] = action\_inputs\["string\_test"].upper()
:::

## Conclusion

Rowan successfully tested his script, verified discovered outputs, and now has the flexibility to handle more complex data manipulation using Python scripts. By validating the inputs and checking discovered outputs, he can confidently use this script in downstream actions within the playbook.
