Skip to main content

Code actions

R
Written by Riya Sebastian
Updated over 3 weeks ago

Unlock advanced automation capabilities within your workflows by executing custom JavaScript code. This feature allows you to implement complex logic, transform data dynamically, and achieve deeper integrations with third-party systems, moving beyond the limitations of predefined actions.

Understand the power of custom scripts

By incorporating custom code into your workflows, you gain granular control over your automation processes. You can:

  • Implement complex business logic: Execute sophisticated conditional logic that goes beyond standard workflow conditions.

  • Transform data on the fly: Modify inputs, reformat data, or prepare data structures for subsequent actions or external systems. You can leverage dynamic values from requests using data pills and placeholders.

  • Integrate with external services: Make API calls to third-party systems using webhooks, fetch data, or trigger actions in other platforms directly from your script.

For instance, imagine you're automating new employee onboarding and need to create user accounts in Okta. A custom script can automatically check if a proposed username already exists. If it does, the script can intelligently modify the username (e.g., changing "[email protected]" to "[email protected]") before proceeding with account creation. This proactive approach helps prevent errors and significantly reduces manual intervention.

Set up a workflow to execute a custom script

To add custom JavaScript to a workflow, follow these steps:

  1. Navigate to Settings > Your workspace > Workflows. You can find more details on general workflow creation in our article on setting up workflows.

  2. Click the Create a workflow button or select an existing workflow to edit.

  3. Enter a name and description for your workflow if creating a new one.

  4. Configure a trigger for your workflow, such as Request is created. Triggers determine when your workflow will run.

  5. Click on Add an action (or the + icon) to add a new step to your workflow.

  6. From the list of available actions, select Execute script.

  7. In the action configuration panel, navigate to the Code tab.

  8. Enter or paste your custom JavaScript code into the editor provided. You can also insert other workflow actions from integrated apps available in the Atomicwork workflow editor like creating a Google Workspace user or adding an employee to an Azure AD group. Alternatively, type "Workflow." to pull up a list of third-party actions from apps you've integrated with Atomicwork.

  9. Once you have added your script, click Done to save the action.

  10. Subsequent actions in workflows can consume and use the JSON output data from this action.

  11. After configuring all triggers, conditions, and actions, click Publish at the top right corner to activate your workflow.

Key Considerations:

  • Data Access: Your scripts can interact with workflow data using data pills and placeholders to dynamically pull request details or outputs from previous actions.

  • External Calls: When integrating with third-party systems, ensure your script handles API calls, authentication, and responses appropriately. You can utilize webhook functionalities within your script logic.

  • Error Handling: Implement robust error handling within your JavaScript to manage unexpected situations and prevent workflow failures.

Executing custom JavaScript opens up a new realm of possibilities for tailoring workflows to your exact needs. By writing your own scripts, you can automate intricate processes, manipulate data with precision, and build powerful integrations.

For more information on related workflow capabilities, explore these articles:

Did this answer your question?