---
displayed_sidebar: workflowsSidebar
slug: /references/workflows/transform
sidebar_label: transform
---

import ParameterTypes from "@site/src/components/ParameterTypes"

# transform - Workflows API Reference

This documentation provides a reference to the `transform` . It belongs to the `@medusajs/workflows-sdk` package.

This function transforms the output of other utility functions.

For example, if you're using the value(s) of some step(s) as an input to a later step. As you can't directly manipulate data in the  workflow constructor function passed to [createWorkflow](workflows.createWorkflow.mdx),
the `transform` function provides access to the runtime value of the step(s) output so that you can manipulate them.

Another example is if you're using the runtime value of some step(s) as the output of a workflow.

If you're also retrieving the output of a hook and want to check if its value is set, you must use a workflow to get the runtime value of that hook.

## Example

```ts
import {
  createWorkflow,
  transform
} from "@medusajs/workflows-sdk"
import { step1, step2 } from "./steps"

type WorkflowInput = {
  name: string
}

type WorkflowOutput = {
  message: string
}

const myWorkflow = createWorkflow<
    WorkflowInput,
    WorkflowOutput
  >
  ("hello-world", (input) => {
    const str1 = step1(input)
    const str2 = step2(input)

    return transform({
      str1,
      str2
    }, (input) => ({
      message: `${input.str1}${input.str2}`
    }))
})
```

## Type Parameters

<ParameterTypes parameters={[
  {
    "name": "T",
    "type": "`object` \\| [WorkflowDataProperties](../types/workflows.WorkflowDataProperties.mdx)&#60;unknown&#62;",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "RFinal",
    "type": "`object`",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

## Parameters

<ParameterTypes parameters={[
  {
    "name": "values",
    "type": "`T`",
    "description": "The output(s) of other step functions.",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "func",
    "type": "[Func1&#60;T, RFinal&#62;]",
    "description": "The transform function used to perform action on the runtime values of the provided `values`.",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

## Returns

<ParameterTypes parameters={[
  {
    "name": "WorkflowData",
    "type": "[WorkflowData](../types/workflows.WorkflowData.mdx)&#60;RFinal&#62;",
    "optional": false,
    "defaultValue": "",
    "description": "There's no expected value to be returned by the `transform` function.",
    "expandable": false,
    "children": []
  }
]} />
