I’m trying to use the new value function ability of Forge custom fields.
I’m trying to set a number field, but everytime I do, I get the error
The field value must be a number.
shown in the UI.
Here is my code:
Manifest
modules:
jira:customField:
- key: customfield-key
name: Number Custom Field
description: This custom field displays a number.
type: number
value:
function: render-number
function:
- key: render-number
handler: index.renderNumber
The function receives a list of issue IDs and returns a list of values for those issues. The values returned must be compatible with the format expected by the Edit Issue REST API operation. For example, for users the value must be an object that contains accountId.
When I write value calculation logic in the function caclulateNumber, there’s always an error:
ERROR 08:17:23.190 96eb1447a1c33cd8 cannot use a hook outside of a component
I don’t know why this pops out. Could you please take a look?
Hi @YY1
The issue here is that you’re using a react hook useState inside of a regular javascript function. You can only use hooks at the top level of a React function (that means from the react function component or another react hook). You can read more about rules of using hooks here: https://reactjs.org/docs/hooks-rules.html .
Instead of doing
When I changed the codes as below, an error pops out:
Can't wrap a non-transferable value (constructor: 'Promise')
Error: Can't wrap a non-transferable value (constructor: 'Promise')
at s.wrap (bootstrap.js:1:1677)
at bootstrap.js:1:2270
at Array.map (<anonymous>)
at s.wrapArray (bootstrap.js:1:2257)
at s.wrap (bootstrap.js:1:1574)
at bootstrap.js:1:797
at Array.map (<anonymous>)
at s.applyIgnored (bootstrap.js:1:784)
at bootstrap.js:1:8730