Create date effective Table
When you set the ValidTimeStateFieldType property it will automatically create the ValidFrom/to fields
Crete a new form from template SimpleListDetails
Drag the table to the datasource
It will set the date effective query to the default:
Then set the grid datasource and add fields to the grid
Create the groups possibly based on the table groups (otherwise drag fields from the datasource one by one)
Add in the init
public void init()
{
super();
//Initialize splitter
verticalSplitter = new SysFormSplitter_X(VSplitter, GridContainer, element, 300);
//For Dates
//DateEffectivenessPaneController::constructWithForm(this, EF_DateEffectiveTrial1_ds);
//For DateTime
DateEffectivenessPaneController::constructWithForm(this, EF_DateEffectiveTrial1_ds, true, true, true);
}
The form will look like this
Change the properties of the datasource like this:
This allows to change the effective dates manually
Create a new Drop Dialog:
Create a new form from template Drop Dialog
Add those two methods
private ValidFromDateTime getEffectiveDate()
{
return effectiveDate.dateTimeValue();
}
public void init()
{
ValidFromDateTime validFromDefaultDate;
ValidToDateTime validToDefaultDate;
Timezone userTimeZone;
EF_DateEffectiveTrial1 common;
super();
common = element.args().record();
userTimeZone = DateTimeUtil::getUserPreferredTimeZone();
validFromDefaultDate = DateTimeUtil::applyTimeZoneOffset(DateTimeUtil::utcNow(), userTimeZone); //common.ValidFrom;
effectiveDate.dateTimeValue(validFromDefaultDate);
//expirationDate.dateValue(validToDefaultDate);
//set the \Forms\EF_DropDialogEffectiveDate\Designs\Design\[Group:DialogCommit]\[ButtonGroup:ButtonGroup]\CommandButton:OKButton
//AutoDeclaration = Yes
OKButton.helpText(strFmt("@SYS327712",tableId2pname(common.TableId)));
}
Create a new menuItem Display
Create a new DropDialog Button
Override the dialogClosed method
public void dialogClosed(FormRun _formRun)
{
Object formRunObj;
ValidFromDateTime effectiveDate;
EF_DateEffectiveTrial1 record, recordNew;
super(_formRun);
formRunObj = _formRun;
if (_formRun.closedOk())
{
if (formHasMethod(formRunObj, 'getEffectiveDate'))
{
effectiveDate = formRunObj.getEffectiveDate();
}
record = EF_DateEffectiveTrial1_ds.cursor();
buf2Buf(record, recordNew);
recordNew.ValidFrom = effectiveDate;
recordNew.insert();
EF_DateEffectiveTrial1_ds.research(true);
}
}
The form will look like this
No comments:
Post a Comment