CustomFieldEdit not saving value

We use a CustomField to query a Yes/No field when creating a task:

https://developer.atlassian.com/platform/forge/ui-kit-components/jira/custom-field-edit/

The dialog also appears successfully, but when clicking on “Save” the value is still displayed again with the old value (“NO”).
Do you guys have any idea what the problem could be?

Here is our code:

manifest.yml

...
jira:customField:
  - key: transfer-to-fv
    name: Transfer Ticket to FV
    description: Transfers the ticket to FV after ticket creation
    edit:
      function: editTransfer
    type: string
    function: viewTransfer
...
  function:
    - key: viewTransfer
      handler: transfer.renderFieldView
    - key: editTransfer
      handler: transfer.renderFieldEdit
...

transfer.jsx:

import ForgeUI, {
    render,
    useProductContext,
    CustomField,
    CustomFieldEdit,
    Text,
    Select,
    Option,
    StatusLozenge,
    Fragment, useState
} from "@forge/ui";

const View = () => {
    const {
        extensionContext: { fieldValue, renderContext,fieldId },
    } = useProductContext();

    return (
        <CustomField>
            <Text>
                <StatusLozenge text={fieldValue ? 'Yes' : 'No'} />
            </Text>
        </CustomField>
    );
};

const Edit = () => {
    const {
        extensionContext: { fieldValue, renderContext },
    } = useProductContext();

    const onSubmit = (formValue) => {
        return formValue.transfer;
    }
    return (
        <CustomFieldEdit onSubmit={onSubmit} header='Transfer' width="medium" >
            <Fragment>
                <Select label="Transfer" name="transfer" isRequired>
                    <Option label="YES" value="1" />
                    <Option label="No" value="0" />
                </Select>
            </Fragment>
        </CustomFieldEdit>
    );
};

export const renderFieldView = render(<View />);
export const renderFieldEdit = render(<Edit />);

Hi Stefan
I’ve tried recreating the issue but unable to get what you’re describing.

What I did notice was you were setting the fieldValue to the strings "1" and "0".
These would always return true in your ternary operator always leaving you with 'Yes' and 'No' in the case where the field isn’t set yet.

1 Like

Thank you for the fast response!

I tried the example app “Forge Risk Assessment Custom Field” and have the same problem there:

https://bitbucket.org/atlassian/forge-risk-assessment-custom-field/src/master/

When I want to create an issue, this is visible:

If I click on this, I can select the values:

When I click Save, the field did not change:

image

I should mention that the app code has not changed for a while. Could it be that there is perhaps a problem with the platform?

I’ve run the risk assessment app under a few screens with the expected result, the field changes immediately.

Would you be able to describe the exact steps you used to recreate the issue? A recording may also be very helpful here.

Additionally would you mind messaging me the app id, the environment type and the installed site so we can check everything looks right on our end.

Thank you very much, Joshu,

here are the infos:

Video: Sign in to your account
App ID: eb6c047c-ec30-4f9b-88c2-d44d8000ba50
Test Environment: https://featvalue.atlassian.net/

So I only want to Select the field while creating a new issue.

That’s very interesting. When running the code you’ve provided I see a different UI

Screen Shot 2022-12-07 at 11.35.07

I’ll have a chat with the team owning this and get back to you

1 Like

Hi Stefan

I’ve had a chat with the team involved and they’re confused by the code snippet you’ve sent and the results you recorded.

There are the fields Impact and Likelihood but we don’t see these anywhere in the snippet you provided.

We suspect you’re using a component that isn’t Select or using the component in a way we didn’t anticipate.

Would you be able to share the code of what was recorded? This will help us debug the issue faster.

I sent you the complete code via private message. Thanks a lot!

The problem was caused by an old version of @forge/ui. Thank you very much Joshua!