Hi,
I previously reported an issue related to window is not defined
, and now I’m encountering the same error again, but in a different context.
I have a trigger defined in my manifest as follows:
trigger:
- key: issue-fields-trigger
function: issue-field-trigger
filter:
expression: event.type.includes("***")
events:
- avi:jira:created:field
- avi:jira:updated:field
- avi:jira:trashed:field
- avi:jira:restored:field
- avi:jira:deleted:field
function:
- key: resolver
handler: index.handler
- key: issue-field-trigger
handler: trigger.run
And the trigger.run
function looks like this:
import { invoke } from "@forge/bridge";
export const run = async (event) => {
let eventType = event.eventType;
const fieldName = event.name;
const fieldID = event.id;
const fieldDescription = event.description;
console.log("Event Type:", eventType);
console.log("Field Name:", fieldName);
console.log("Field ID:", fieldID);
console.log("Field Description:", fieldDescription);
const data = {
fieldID,
fieldName,
fieldDescription
};
const getStoredData = await invoke('getStorage', { key: 'myKey' });
const storedData = (getStoredData.status === 200 && getStoredData.res) ? getStoredData.res : [];
let updatedData = [...storedData, data];
const responseStorage = await invoke('setStorage', { key: 'issuePicker', value: updatedData });
if (responseStorage.status !== 200) {
console.error("Error setting storage:", responseStorage.message);
return;
}
}
When this trigger is executed, I’m getting a window is not defined
error. I assume this may be due to the usage of @forge/bridge
within the trigger function context, which is server-side.
Could you please advise on how to properly handle this case or suggest an alternative way to achieve the same functionality?
Thank you in advance.
Best regards,
Mertcan.