Switching between Disabled and Enabled fields function
I needed to set several fields to disabled or enabled based on a status field. To do this in people code was easy enough using the field DERIVED_REC.EXT_ORG_ID.Enabled = False and DERIVED_REC.EXT_ORG_ID.DisplayOnly = True to disable. However to enabled I'd have to repeat that code with the opposite values. Often this switching is necessary in several places so I built this way of making the change in a function.
Example
I put the function in the first field FieldFormula of the record. Then you simple declare you function where you need it and call it with a boolean value.Declare Function allowEditFields PeopleCode DERIVED_REC.EMPLID FieldFormula;
allowEditFields( True);
- Function allowEditFields(&ENABLE);
- Local boolean &enabled;
- Local boolean &displayOnly;
- If &ENABLE Then;
- &enabled = True;
- &displayOnly = False;
- Else
- &enabled = False;
- &displayOnly = True;
- End-If;
- DERIVED_REC.STRM.Enabled = &enabled;
- DERIVED_REC.STRM.DisplayOnly = &displayOnly;
- DERIVED_REC.EXT_ORG_ID.Enabled = &enabled;
- DERIVED_REC.EXT_ORG_ID.DisplayOnly = &displayOnly;
- DERIVED_REC.MCM_TR_TO_DT.Enabled = &enabled;
- DERIVED_REC.MCM_TR_TO_DT.DisplayOnly = &displayOnly;
- DERIVED_REC.MCM_TR_FROM_DT.Enabled = &enabled;
- DERIVED_REC.MCM_TR_FROM_DT.DisplayOnly = &displayOnly;
- DERIVED_REC.MCM_TR_PROG.Enabled = &enabled;
- DERIVED_REC.MCM_TR_PROG.DisplayOnly = &displayOnly;
- DERIVED_REC.MCM_TR_PREV_ATD.Enabled = &enabled;
- DERIVED_REC.MCM_TR_PREV_ATD.DisplayOnly = &displayOnly;
- DERIVED_REC.MCM_TR_STDNT_ID.Enabled = &enabled;
- DERIVED_REC.MCM_TR_STDNT_ID.DisplayOnly = &displayOnly;
- DERIVED_REC.ADD_PB.Enabled = &enabled;
- DERIVED_REC.UPDATE_PB.Enabled = &enabled;
- DERIVED_REC.PRINT_BTN.Enabled = &enabled;
- End-Function;