Access the whole entity property object from a Forge Jira custom field rendering function

When it comes to performing a REST call when rendering Custom Field module, it is possible with the use of useAction UI hook - please check out the example below:

import ForgeUI, { CustomField, CustomFieldEdit, useAction, render, Text, TextField, useProductContext } from "@forge/ui";
import api from '@forge/api';

const checkProperties = async () => {
    const result = await api
        .asApp()
        .requestJira(
            `/rest/api/3/issue/SKIP-3/properties`
        );

    return await result.json().then(data => {
        return data;
    })
};

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

    const [value, setValue] = useAction(
        () => checkProperties(),
        () => checkProperties(),
    );

    console.log(value);

  return (
    <CustomField>
      <Text
        content={`Hello ${fieldValue || "world"}!`}
      />
    </CustomField>
  );
};

const Edit = () => {
  const onSubmit = values => {
      return values.text
  };

  return (
    <CustomFieldEdit onSubmit={onSubmit}>
      <TextField name="text" label="Say hello to:"></TextField>
    </ CustomFieldEdit>
  );
}

export const runView = render(
  <View/>
);

export const runEdit = render(<Edit/>)

This way I got a list of issue properties logged in the console with forge tunnel.

Thank you,
Mateusz

2 Likes