Hello,
I created a custom UI Jira Dashboard app and updated the getText resolver to return a object. Later changed to return a string.
From the Front-end in the Edit component I am invoking the getText resolver. This returns data in both format object and string. I updated the state after getting data from the resolver.
I am trying to display data returned from getText but I am getting below error. Not sure if this is related to my code. This error is show soon as the setData is called.
Here is the code of the resolver:
import Resolver from '@forge/resolver';
const resolver = new Resolver();
resolver.define('getText', (req) => {
console.log('getText is called');
console.log(req);
var result = {key: 'f', fields: { summary: 's', customfield_10011: '11', customfield_10087: '87', assignee: { displayName: 'n'}}};
try {
console.log('try');
result = {
key: 'The Key',
fields: {
summary: 'The Summary',
customfield_10011: 'Custom field 10011',
customfield_10087: 'Custom field 10087',
assignee: {
displayName: 'Full name'
},
},
};
console.log('end of try');
} catch (e) {
console.log(`catch: error: ${JSON.stringify(e)}`);
} finally {
return JSON.stringify(result);
}
});
export const handler = resolver.getDefinitions();
Code of the Edit form:
import React, { useEffect, useState } from 'react';
import Form, { Field } from '@atlaskit/form';
import TextField from '@atlaskit/textfield';
import Button, { ButtonGroup } from '@atlaskit/button';
import { view, invoke } from '@forge/bridge';
function Edit() {
const [data, setData] = useState(null);
const onSubmit = (formData) => view.submit(formData);
useEffect(async () => {
const re = await invoke('getText', {sendingData: 'abcd'});
setData(JSON.parse(re));
});
return (
<div>
<div>This is Edit form</div>
<div style={{fontSize: "16px"}}>Key {data?.key} </div>
<div style={{fontSize: "16px"}}>Summary {data?.fields?.summary}</div>
<div style={{fontSize: "16px"}}>Name {data?.fields?.assignee?.displayName}</div>
</div>
);
}
export default Edit;
To deploy I follow below steps:
On the static\hello-world folder
-npm run install
-npm run build
forge deploy
forge install