Set custom field in config-as-code mode
Asked by Daniele Somma:

Exploring the Compass product, I took the config-as-code way to manage our components.  
For my components I setupped a simple custom field, a checkbox.  
How I can set the value of the custom field with the YAML config file?  
I read your guides about custom fields and YAML fields (<https://developer.atlassian.com/cloud/compass/components/create-view-edit-and-delete-custom-fields/> and <https://developer.atlassian.com/cloud/compass/config-as-code/structure-and-contents-of-a-compass-yml-file/> and <https://community.atlassian.com/t5/Compass-Alpha-articles/Unleash-your-Custom-Field-creativity/ba-p/2030132>), but no one expose a way to do this.  
Exist a way to do this or this feature is not yet supported?

Thanks


Answers:
author: Josh Campbell
body: Hey Daniele you've bumped into one of a few things config-as-code does not currently support. The ability to manage custom fields, labels, component type, and lifecycle are all missing right now and it's on our roadmap to correct this. I have also taken an action item to update our documentation and call this out.

That said, you can update custom field values programmatically using our GraphQL API using the [updateComponent mutation](https://developer.atlassian.com/cloud/compass/graphql/#mutations_updateComponent). Here is a sample to point you in the right direction:

```
mutation compass_component_updateCustomField {  compass {    __typename    updateComponent(      input: {        id: "yourComponentId"        customFields: {          textField: {            definitionId: "yourCustomFieldDefinitionId",            textValue: "New value"          }        },       }    ) {      success      errors {        message        extensions {          errorType          __typename        }        __typename      }      __typename    }  }}
```

Hopefully this helps!

comments: author: Daniele Somma
body: Hi Josh,  
thanks for your reply. To help other with the same need, could be helpfull add some info. The field:

```
"definitionId: "yourCustomFieldDefinitionId"
```

requiring to provide the custom field id.

I haven't found a way to get the id of custom fields from Compass web site, so I used this GraphQL query:

```

query getComponentById($componentId: ID!) {
compass {
component(id: $componentId) {
__typename
... on CompassComponent {
name
typeId
customFields {
... on CompassCustomField {
__typename
... on CompassCustomBooleanField {
definition {
id
name
description
}
booleanValue
}
}
}
}
}
}
}
```

I used the **CompassCustomBooleanField** field, because my custom field is boolean type. It's possible use:

* CompassCustomBooleanField
* CompassCustomNumberField
* CompassCustomTextField

If you have a easyest way, please share it.

That said, some questions:

1. do you know when the ability to set this fields with YAML file, will be release?
2. there are REST API to do the same?

Thanks for your support.


author: Josh Campbell
body: Hey Daniele sorry for the delay. I think you are asking if there is a better way to get all custom field IDs, if so try this:

```
query compass_customFields_getCustomFieldDefinitions {
  compass {
    customFieldDefinitions(query: {
      cloudId: "yourCloudId"
    }) {
      ... on CompassCustomFieldDefinitionsConnection {
         nodes {
          id
          name
          description
          componentTypeIds
          __typename
         }
        __typename
       }
      __typename
     }
    __typename
   }
}
```

Answering your other questions:

1. I don't have a firm release date for supporting custom fields in config-as-code but I can tell you it's on our near term roadmap. I am aiming to ship several improvements to config-as-code first quarter of 2023, including this, but don't want to make any promises :)

2. There is not, sorry. Is GraphQL a hurdle?


author: Daniele Somma
body: Hi Josh,  
thanks for your reply.

Your query is more precise of mine, thanks.

GraphQL is powerfull, but we usually built our processes with YAML pipelines, that can easly integrate thirt part systems throught REST API.

Thanks for your support.


Tags: custom-field

yaml