Hi,
The project ID is not available in the context data. I would like to know how to add my project ID to it. I have also added the context data JSON as below.
Could you please let me know how to add projectID to the context data JSON?
This is the backend code
resolver.define("addOptionToCustomField", async ({ payload }) => {
console.log("addOptionToCustomField")
const { fieldId, name, projectId } = payload
console.log("projectkey.........", projectId)
try {
console.log("Payload to create options...", fieldId)
const contextResponse = await api.asApp().requestJira(route`/rest/api/3/field/${fieldId}/context`, {
method: "GET",
headers: { "Accept": "application/json" },
});
const contextData = await contextResponse.json();
console.log("contextData......", contextData)
console.log("payload.projectId.........", projectId)
const targetContext = contextData.values.find(ctx =>
ctx.projectIds && ctx.projectIds.includes(projectId)
);
console.log("targetContext........", targetContext)
const optionData = [{ value: name }];
console.log("Option Data........", optionData)
var res = await api.asApp().requestJira(route`/rest/api/3/field/${fieldId}/context/${targetContext.id}/option`, {
method: "POST",
headers: {
"Accept": "application/json",
"Content-Type": "application/json",
},
body: JSON.stringify({ options: optionData }),
});
const data = await res.json()
console.log(`✅ Dropdown options added for ${fieldId}!...`, data);
return data
}
catch (error) {
return { "code": 2000, "message": "Error while creating folder" }
}
});
JSON
contextData...... {
maxResults: 50,
startAt: 0,
total: 1,
isLast: true,
values: [
{
id: '12823',
name: 'Default Configuration Scheme for Folders',
description: 'Default configuration scheme generated by Jira',
isGlobalContext: true,
isAnyIssueType: true
}
]
}
The reason you're not getting projectId in the context data is because the context is global (isGlobalContext: true
). It is not bound to any specific project, so projectId is not present.
To get projectId included in the context data, you need to create a custom field context scoped to a specific project rather than a global one.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.