Forge Custom field can't edit default Value by /rest/api/3/field/{fieldID}/context/defaultValue API

Hey Forge Team.

Jira provides the following endpoint https://Youdomain.atlassian.net/rest/api/3/field/customfield_10051/context/defaultValue to modify the default value of the custom field with the following request:

PUT /rest/api/3/field/customfield_10052/context/defaultValue HTTP/2
Host: YourDomain.atlassian.net
User-Agent: Mozilla/5.0
Content-Type: application/json
Content-Length: 113
Cookie: <Admin-Cookies>

{  "defaultValues": [ {  "contextId": "10152", "text": "TEST","type": "textarea"  } ] }

When creating a custom field using Forge of type string I tried to modify the default value of the field through the same request attached previously, but the server replied that there was an error in the custom field type I tried to change the value of the parameter “Type”:

{ “defaultValues”: [ { “contextId”: “10152”, “text”: “TEST”,“type”: “string” } ] }
{ “defaultValues”: [ { “contextId”: “10152”, “text”: “TEST”,“type”: “text” } ] }
{ “defaultValues”: [ { “contextId”: “10152”, “text”: “TEST”,“type”: “textarea” } ] }

but the following error keeps appearing

HTTP/2 400 Bad Request
Server: AtlassianProxy/1.19.3.1
Cache-Control: no-cache, no-store, no-transform
Content-Type: application/json;charset=UTF-8
....

{"errorMessages":["Could not resolve type id 'String' into a subtype of [simple type, class com.atlassian.jira.bc.customfield.defaultvalue.CustomFieldContextDefaultValueBean]\n at [Source: org.apache.catalina.connector.CoyoteInputStream@12096bbc; line: 5, column: 19] (through reference chain: com.atlassian.jira.bc.customfield.defaultvalue.update.CustomFieldContextDefaultValueUpdateRequestBean[\"defaultValues\"])"]}

So please, could you tell me the type of Forge custom field that I should use so that I can modify the default value of the field through the previous request.

Best,

  • Jafar
1 Like

Hello, @JafarAboNada,

This API is not supported for Forge custom fields yet.

1 Like

Hi @kkercz

Thank you for your reply. Is there another way that I can modify the default value of the custom field through the Forge app.

Best,

1 Like

I’m afraid right now setting default values of Forge custom fields can be done only by Jira admins in the UI. We will look into prioritizing the work to make it possible using the REST API.

2 Likes

Thank you very much. Can you create a Trello card or Jira issue for the development team to add the ability to modify string fields through the REST API

1 Like

Hi @JafarAboNada,
we have just finished rollout of the feature that extends aforementioned get/set API for default values of custom fields - now it supports Forge custom fields as well.
https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-custom-field-contexts/#api-rest-api-3-field-fieldid-context-defaultvalue-get

2 Likes

Hi @ljarzabek

Thank you for your reply. Great news, Can the new types also be used to create custom fields, or does the update only include updating the fields?

POST /rest/api/2/field HTTP/2

<....>

{
  "searcherKey": "com.atlassian.jira.plugin.system.customfieldtypes:forgestring",
  "name": "New custom field",
  "description": "Custom field for picking groups",
  "type": "forge.string"
}

Best,
-Jafar

1 Like

Hi @JafarAboNada,

Since Forge custom fields types are not built-in types, API for creating custom fields requires specific ID of Forge custom field type. That’s why it has to be an ID in format: ari:cloud:ecosystem::extension/e62f20a2-4b61-4dbe-bfb9-9a88b5e3ac84/548c5df1-24aa-4f7c-bbbb-3038d947cb05/static/my-cf-type-key

In latest update for setting/getting default custom field values API, we use general data type that is supported by Forge custom fields https://developer.atlassian.com/platform/forge/manifest-reference/modules/jira-custom-field-type/#data-types but it cannot be used as a replacement for extension ID when field is created.

Best regards,
Łukasz

1 Like

Hi @ljarzabek & @kkercz,

Does forge support modifying default values for custom fields for “Jira Product Discovery” such as “Reactions” field?

If not available, can you provide this?

Best regards,

Custom field default values can be set with the following REST API (available also for Forge apps): Set custom field contexts default values. I’m not familiar with the “Reactions” field, and if Jira even supports setting its default values like for other fields (which would be a prerequisite for the API to work). If it turns out it’s not supported by that API, feel free to create a feature request via Atlassian Support.

Hi @kkercz

thank you for your reply. I actually tried using the forge.string custom field types but unfortunately I was getting an error message telling me that the type does not match. So I created a ticket to provide this feature

Ticket link