Hi ,
I’ve created custom field which is a dropdown. So, for that I am adding the options dynamically using the below APIs
API URL'S
1. /rest/api/3/field/${fieldId}/context
2. /rest/api/3/field/${fieldId}/context/${globalContext.id}/option
The options are added successfully, but it is not project specific. The options are visible under all the projects under my account. So i need a way to apply project scope for each option I create.
Any guidance or insights from the community on how to proceed functionality it would be greatly appreciated.
I’ve attached the relevant code snippet below.
resolver.define("addOptionToCustomField", async({payload}) => {
const { fieldId, name } = payload
try{
const contextResponse = await api.asApp().requestJira(route`/rest/api/3/field/${fieldId}/context`, {
method: "GET",
headers: { "Accept": "application/json" },
});
const contextData = await contextResponse.json();
const globalContext = contextData.values.find(ctx => ctx.isGlobalContext);
const optionData = [{ value: name }];
var res = await api.asApp().requestJira(route`/rest/api/3/field/${fieldId}/context/${globalContext.id}/option`, {
method: "POST",
headers: {
"Accept": "application/json",
"Content-Type": "application/json",
},
body: JSON.stringify({options: optionData}),
});
const data = await res.json()
return data
}
catch(error){
return {"code": 2000, "message": "Error while creating folder"}
}
});Thanks in advance for your help!