Hi Team,
I’m building a solution in Jira using Forge.
I have four fields:
I would really appreciate any simple and practical workaround suggestions by using forge.
Hi @Paidipati_ Lokesh , reach for UI modifications here. You point a jira:uiModifications module at the Issue view, and in its onInit and onChange handlers you read the Status field and flip Pincode with setReadOnly(true) when it equals In-Progress and setReadOnly(false) for To-Do or Closed. That is the whole behaviour you described, and the same module covers the create and transition screens too if you want it there.
The one trap is the field itself. UI modifications drives Jira's standard fields, not Forge custom fields, so it is clean if Pincode is an ordinary text custom field; if you built Pincode as a Forge field instead, UI modifications can't touch it and you would make that field's own edit component render read-only while the issue sits in In-Progress. Either way it only locks the input in the UI, not the REST API or automation, so add a workflow validator if the rule has to be airtight. The handler shape and the supported-field tables are in Atlassian's UI modifications guide.
Hi,
You can do something like this in Forge and UIKit.
Note: this is not tested and can contain errors.
// TODO: Import required modules
function Edit() {
const context = useProductContext();
const [readOnly, setReadOnly] = useState(null)
const [value, setValue] = useState(context.extension.fieldValue)
const onSubmit = useCallback(() => {
view.submit(value)
}, [value])
useEffect(()=>{
const init = async () => {
const result = await requestJira(`/rest/api/latest/issue/${context.extension.issue.id}`)
const issue = await result.json()
if(issue.fields.status.name === "In Progress") {
setReadOnly(true)
} else {
setReadOnly(false)
}
}
context.issue.id ? init() : setReadOnly(false)
}, [])
if (readOnly === null) {
return <Spinner />
}
return (
<CustomFieldEdit onSubmit={onSubmit}>
<Textfield isReadOnly={readOnly} defaultValue={value} onChange={(e) => {setValue(e.target.value)}}/>
{readOnly && <ErrorMessage>Edit is not allowed</ErrorMessage>}
</CustomFieldEdit>
)
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.