younifyd
Menu

updateState

Update an existing state — pass its current version and an array of update actions.

Use it in a workflow

  1. Add a step and choose the Commercetools connector.
  2. Pick the updateState action (under Update).
  3. Fill in the fields below, then reference the result from later steps as {{updatestate.response.data}}.

Query

This is the mutation the action sends by default. Edit it in the step's Query field to change which fields come back.

graphql
mutation UpdateState($version: Long!, $actions: [StateUpdateAction!]!, $id: String, $key: String) {
  updateState(version: $version, actions: $actions, id: $id, key: $key) {
    id
    version
    key
    type
    roles
    nameAllLocales {
      locale
      value
    }
    descriptionAllLocales {
      locale
      value
    }
    builtIn
    transitionsRef {
      typeId
      id
    }
    transitions
    initial
    createdAt
    lastModifiedAt
    createdBy {
      isPlatformClient
      clientId
      externalUserId
      anonymousId
      customerRef {
        typeId
        id
      }
      userRef {
        typeId
        id
      }
      associateRef {
        typeId
        id
      }
      attributedTo {
        clientId
        source
        userRef
      }
    }
    lastModifiedBy {
      isPlatformClient
      clientId
      externalUserId
      anonymousId
      customerRef {
        typeId
        id
      }
      userRef {
        typeId
        id
      }
      associateRef {
        typeId
        id
      }
      attributedTo {
        clientId
        source
        userRef
      }
    }
  }
}

Variables

Pass these as a JSON object in the step's Variables field.

versionstringrequired
actionsarray<object>required
addRolesobject1 fields
changeInitialobject1 fields
changeKeyobject1 fields
changeTypeobject1 fields
removeRolesobject1 fields
setDescriptionobject1 fields
setNameobject1 fields
setRolesobject1 fields
setTransitionsobject1 fields
idstring

Queries with specified ID

keystring

Queries with specified key

json
{
  "version": "string",
  "actions": [
    {
      "addRoles": {
        "roles": "string"
      },
      "changeInitial": {
        "initial": "string"
      },
      "changeKey": {
        "key": "string"
      },
      "changeType": {
        "type": "string"
      },
      "removeRoles": {
        "roles": "string"
      },
      "setDescription": {
        "description": "string"
      },
      "setName": {
        "name": "string"
      },
      "setRoles": {
        "roles": "string"
      },
      "setTransitions": {
        "transitions": "string"
      }
    }
  ],
  "id": "string",
  "key": "string"
}

Response

Read the result with {{updatestate.response.data.data.updateState}}. If the API returns errors, the step fails and they are at {{updatestate.response.data.errors}}.

idstring
versionstring
keystring
typestring

One ofLineItemStateOrderStatePaymentStateProductStateQuoteRequestStateQuoteStateRecurringOrderStateReviewStateStagedQuoteState

rolesarray<string>
nameAllLocalesarray<object>
localeobject
valueobject
descriptionAllLocalesarray<object>
localeobject
valueobject
builtInboolean
transitionsRefarray<object>
typeIdobject
idobject
transitionsarray<object>
initialboolean
createdAtstring
lastModifiedAtstring
createdByobject
isPlatformClientboolean
clientIdstring
externalUserIdstring
anonymousIdstring
customerRefobject2 fields
userRefobject2 fields
associateRefobject2 fields
attributedToobject3 fields
lastModifiedByobject
isPlatformClientboolean
clientIdstring
externalUserIdstring
anonymousIdstring
customerRefobject2 fields
userRefobject2 fields
associateRefobject2 fields
attributedToobject3 fields

Need more? See the Commercetools guide for connection setup and behaviour shared by every action.

updateState — Commercetools — Documentation