Hi Community,
this my first try on a forge customField and i’ve actually a problem with rendering the view on a UI-Kit CustomField. The CustomField can be edited by a popover with a UserPicker. On the first submit from the edit-dialog it all works fine and the view is renderd correctly. But if i edit the CF again and change the picked user the view isn’t rendered anymore on submit.
(Just for completion: The view uses the accountId to find issues where the user is already reporter and displays that.)
here are the view and edit handlers. maybe anybody has a clue what i’am doing wrong?
const View = () => {
const context = useProductContext();
const { extensionContext: { fieldValue } } = useProductContext();
const { extensionContext: { renderContext } } = useProductContext();
var issues;
var userDisplayName;
var accountId;
if(fieldValue){
accountId = fieldValue.customer;
[issues] = useState(async () => await fetchIssues(context.platformContext.projectKey, accountId));
[userDisplayName] = useState(async () => await getUsernameByAccountId(accountId));
}
console.log("renderContext=" + renderContext);
console.log("accountId=" + accountId);
return (
<CustomField>
<Text
content={`${userDisplayName || "Please pick a User/Customer ..."}`}
/>
{(issues && issues.length>0)? (
<Text>
{`is already reporter in ${issues.length} tickets in status: `}
<StatusLozenge text="In progress" appearance="inprogress" />
</Text>
) : (
<Text>{userDisplayName?`this user has currently no open tickets ...`:""} </Text>
)}
</CustomField>
);
};
const Edit = () => {
const { extensionContext: { fieldValue } } = useProductContext();
const onSubmit = values => {
console.log("Submitting accountId=" + values.customer);
return values;
};
//console.log("stored accountId=" + accountId);
return (
<CustomFieldEdit onSubmit={onSubmit} header={`Pick User/Customer`} >
<UserPicker
description="Please pick a user/customer"
name="customer"
defaultValue={`${fieldValue}`}
/>
</ CustomFieldEdit>
);
}