<!--
{
  "availability" : [
    "macCatalyst: 14.0.0 -",
    "macOS: 10.4.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Automator",
  "identifier" : "/documentation/Automator/AMWorkflow/setValue(_:forVariableWithName:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Automator"
    ],
    "preciseIdentifier" : "c:objc(cs)AMWorkflow(im)setValue:forVariableWithName:"
  },
  "title" : "setValue(_:forVariableWithName:)"
}
-->

# setValue(_:forVariableWithName:)

Sets the value of the workflow variable with the specified name.

```
func setValue(_ value: Any?, forVariableWithName variableName: String) -> Bool
```

## Parameters

`value`

The value to set for the named variable.

`variableName`

The name of a variable to set the value for.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if `variableName` was found and its value is set; otherwise <doc://com.apple.documentation/documentation/Swift/false>.

## Discussion

This method does nothing if the variable specified by `variableName` is not found.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)