Wednesday, November 7, 2012

Storing last form values


1. In the AOT, find the LedgerJournalTable form, and add the following code to the bottom of its class declaration:

AllOpenPosted showStatus;
NoYes showCurrentUser;
#define.CurrentVersion(1)
#localmacro.CurrentList
showStatus,
showCurrentUser
#endmacro

2. Create the following additional form methods:
public void initParmDefault()
{
    showStatus = AllOpenPosted::Open;
    showCurrentUser = true;
}


public container pack()
{
    return [#CurrentVersion, #CurrentList];
}


public boolean unpack(container _packedClass)
{
    int version = RunBase::getVersion(_packedClass);


    switch (version)
    {
        case #CurrentVersion:
        [version, #CurrentList] = _packedClass;
        return true;
        default:
        return false;
    }
    return false;
}


public IdentifierName lastValueDesignName()
{
    return element.args().menuItemName();
}


public IdentifierName lastValueElementName()
{
    return this.name();
}


public UtilElementType lastValueType()
{
    return UtilElementType::Form;
}


public UserId lastValueUserId()
{
    return curUserId();
}


public DataAreaId lastValueDataAreaId()
{
    return curext();
}


3. Add the following code to the form's run() method right before its super():

xSysLastValue::getLast(this);
AllOpenPostedField.selection(showStatus);
ShowUserCreatedOnly.value(showCurrentUser);

4. Add the following code to the bottom of the form's close() method:

showStatus = AllOpenPostedField.selection();
showCurrentUser = ShowUserCreatedOnly.value();
xSysLastValue::saveLast(this);


No comments: