Form API Reference
Here you can find the reference for the Form API and learn how to establish a connection to the form.
Establish a Connection
The first step for using the Form API is establishing a connection to the form. To do that, use the sample code below with the ID of the form you're working with.
You can get the form ID from the embed code for the form.
Predefined Fields
There are three predefined form fields that you can refer to by their names:
email
summary
description
Sample code:
Methods
getBlocks
The getBlocks
method lets you get the blocks available for the form.
Sample: getBlocks()
Returned Value
Type | Description |
---|---|
Array<Block> | An array of blocks available for the form. |
getBlockValue
The getBlockValue
method lets you get the value of the particular block in the form. This method is useful when you need to prefill a block value based on a value entered by the user in another block.
Sample: getBlockValue(blockReference)
Parameters
Name | Type | Description |
---|---|---|
blockReference | String | The ID or the title of the block. |
Returned Value
Type | Description |
---|---|
Value | The value of the block. |
getBlockValues
The getBlockValues
method lets you get the list of available values for the particular block in the form. Works only when the block is represented by an enumerated custom field in YouTrack.
Sample: getBlockValues(blockReference)
Parameters
Name | Type | Description |
---|---|---|
blockReference | String | The ID or the title of the block. |
Returned Value
Type | Description |
---|---|
Array<Value> | An array of available values for the block. |
setBlockValue
The setBlockValue
method lets you set the value in a block in the form.
Sample: setBlockValue(blockReference, newValue)
Parameters
Name | Type | Description |
---|---|---|
blockReference | String | The ID or the title of the block. |
newValue | String | The new value for the block. For the values of an enumerated field, you can use the ID of the corresponding block value. |