Hi @JarosawWitowski,
thank you for your response.
I will try add all info:
- I create custom field:
METHOD : POST
URL: .../rest/api/3/field
BODY:
{
"name": "WHVID",
"description": "Description of custom field...",
"type": "com.atlassian.jira.plugin.system.customfieldtypes:readonlyfield",
"searcherKey": "com.atlassian.jira.plugin.system.customfieldtypes:textsearcher"
}
RESPONSE: 201
{
"id": "customfield_10078",
"key": "customfield_10078",
"name": "WHVID",
"untranslatedName": "WHVID",
"custom": true,
"orderable": true,
"navigable": true,
"searchable": true,
"clauseNames": [
"cf[10078]",
"WHVID",
"WHVID[Short text]"
],
"schema": {
"type": "string",
"custom": "com.atlassian.jira.plugin.system.customfieldtypes:readonlyfield",
"customId": 10078
}
}
-
They I assign this custom field to Default screen:
METHOD: POST
URL: /rest/api/3/screens/addToDefault/customfield_10078
RESPONSE: 200
"CREATED"
-
Try to create issue:
METHOD: POST
URL: .../rest/api/3/issue
BODY:
{
"fields": {
"summary": "Main order flow broken",
"issuetype": {
"id": "10000"
},
"customfield_10078": "CUSTOM VALUE",
"project": {
"key": "DA"
},
"description": {
"type": "doc",
"version": 1,
"content": [
{
"type": "paragraph",
"content": [
{
"text": "Some description...",
"type": "text"
}
]
}
]
},
"priority": {
"id": "20000"
}
}
}
RESPONS: 400
{
"errorMessages": [],
"errors": {
"customfield_10078": "Field 'customfield_10078' cannot be set. It is not on the appropriate screen, or unknown."
}
}
NOTE:
So I did not find any easy way to add custom field to specifics projects.
My workaround was:
- Pull all projects
- Get all screens of all projects
- Get all tabs of all screens
- assign this custom field to all tabs
But this work just with few projects (~3-4), if I need to do it for more projects, or if projects have many screens I will of course get 429
(rate limit).
How can I handle this situation, if I can not predict on which screens will be custom field used?
Thank you