# How to Pass Variables Between Parent and Child Kanbans

There are two ways to pass variables between parent and child kanbans:

* Input Variables
* Update Variables action

### Input Variables

{% hint style="warning" %}
Input Variables are way to pass variables from Parent to Child Kanban only.
{% endhint %}

Input Variables are passed to the child kanban immediately when it is loaded inside the parent.

These variables can be:

* already defined on the child kanban. When Input Variables have the same names as variables configured in the child kanban, their values override those variables on the child kanban
* new custom variables

To set Input Variables select a [Child Kanban](https://docs.flexikanban.ai/composite-kanban/working-with-composite-kanban-layout/configuring-child-kanban) in the Composite Kanban editor and click "add" link in the properties sidebar:

<img src="https://3097383375-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FK2dgObBO5ydOH2ZXDJLa%2Fuploads%2FbnfE46koMhQrBhwXDzSB%2Ffile.excalidraw.svg?alt=media&#x26;token=f290e68c-1364-453a-9c0c-a825401c08a3" alt="" class="gitbook-drawing">

A Variable entry form will appear. If selected child kanban has variables configured, their names will be added to Name field picker:

<img src="https://3097383375-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FK2dgObBO5ydOH2ZXDJLa%2Fuploads%2FjpbYDFlrKwjUJa8Sm5UY%2Ffile.excalidraw.svg?alt=media&#x26;token=eaeab9ad-536f-4c04-a7ac-a443102fec85" alt="" class="gitbook-drawing">

You can select one of these names. If you want to add other variable, select "*...Custom*" option - pickilst will transform to text input and you can type desired variable name. Enter necessary value or use ">>" button to show assistive Formula Editor. Click "Remove Variable" button to deleteariable entry:

<img src="https://3097383375-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FK2dgObBO5ydOH2ZXDJLa%2Fuploads%2FmSBwQ7rXm2j2gB7VnJmB%2Ffile.excalidraw.svg?alt=media&#x26;token=4f599201-d1bc-4eb9-9f1c-2e3ebc539631" alt="" class="gitbook-drawing">

Save Kanban. Now, when it will be opened, these input variables will be passed to child Kanban.

### "Update Variables" Action

This action uses Kanban API "Update variables" method. It works for any Kanban, so, we can do this action as for Child, as for Parent kanbans.

This action can't be executed automatically when Kanban is loaded, so, it should be set as a handler on some Child Kanban element:

<img src="https://3097383375-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FK2dgObBO5ydOH2ZXDJLa%2Fuploads%2FpIYI1RugB94vuMui0F6B%2Ffile.excalidraw.svg?alt=media&#x26;token=c935d96c-a561-4780-b8d7-38024e4cd2fa" alt="" class="gitbook-drawing">

This method requires two parameters: "variables" with necessary variables and their values in JSON format and "kanbans" with list of Kanban IDs or names (separated with comma or in JSON format):

<img src="https://3097383375-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FK2dgObBO5ydOH2ZXDJLa%2Fuploads%2FvYlTWJEpYE4reveZBCfk%2Ffile.excalidraw.svg?alt=media&#x26;token=61507f71-d33f-475a-8fab-e697749f3d1b" alt="" class="gitbook-drawing">

### Using Kanban API Names

The main trouble in using of this method is that kanban IDs is unknown by default (and will be changed by system while cloning, importing or deployment). Also Kanban name can be changed, become non-unique or too long. At east, it is not good idea to hardcode something dynamic.

Child Kanbans can have API names. They can be set in the [child Kanban properties](https://docs.flexikanban.ai/composite-kanban/working-with-composite-kanban-layout/configuring-child-kanban):

<img src="https://3097383375-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FK2dgObBO5ydOH2ZXDJLa%2Fuploads%2FjHNfvQg3g7KZEISAt7Wr%2Ffile.excalidraw.svg?alt=media&#x26;token=e87c60ff-6c1b-4633-a9b3-c92004733d6f" alt="" class="gitbook-drawing">

These API names can be used instead of Kanban IDs in various actions (like Update Variable) and will be usable even when IDs of kanbans were changed.

### Solving problems: how to know parent Kanban ID in the child kanban

Since API names can be set only to Child Kanbans, in is no simple way to make parent Kanban a target for Kanban API actions.

In this case we can use Input Variables to pass parent Kanban ID (or name) to children:

1. Set some variable (e.g. name it "ChildVar") in parent Kanban
2. Set Input Variable for Child Kanban and give it "{$Kanban.ID} value
3. Configure some element with in Child Kanban. Give it a handler which will update some variable in the parent one, and set {$Variables.parentID} as value of "kanbans" parameter
4. Set "variables" parameter to some value (e.g, {"ChildVar":"Value\_from\_child\_kanban"})

<img src="https://3097383375-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FK2dgObBO5ydOH2ZXDJLa%2Fuploads%2Fy75XuxaeA5DdzoaytEPU%2Ffile.excalidraw.svg?alt=media&#x26;token=69aa1a38-e877-48cb-be6b-29c154e8e598" alt="" class="gitbook-drawing">

Now if click this child Kanban element it will trigger Update Variable action on target (parent) Kanban. You can know this using Debug Console:

1. See the Parent Kanban variable initial value
2. Close console and click on element to trigger "Update Variable" action
3. See the Parent Kanban variable new value:

<img src="https://3097383375-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FK2dgObBO5ydOH2ZXDJLa%2Fuploads%2FbUqcnoyqF0U5pLuJPOJV%2Ffile.excalidraw.svg?alt=media&#x26;token=af144693-53bf-4d8d-921f-58f188041c69" alt="" class="gitbook-drawing">

{% hint style="info" %}
You may not define a "ChildVar" variable on Parent Kanban - in this case it will have no initial value, but will be created when Update Variable action will be executed first time.
{% endhint %}
