July 25, 2012

Add a button to go to Main Transaction

Add a button to go to Main Transaction

Hi guys,

The following code for adding a button on your forms to go to the main transaction form/table, to do this type of magic you have to add a button on you form and copy paste the following code in the click method of that button.

void clicked()
{
    Common buffer;
    selectableDataArea company = curExt();
    Args args = new Args();
    SysDictTable dictTable;
    FormRun formRun;
    WorkflowTrackingStatusTable trackingStatus;
    ;
    trackingStatus = WorkflowTrackingStatusTable::findByCorrelation(WorkflowTrackingStatusTable.CorrelationId);
    if (trackingStatus.RecId)
    {
        changecompany(trackingStatus.ContextCompanyId)
        {
            dictTable = new SysDictTable(trackingStatus.ContextTableId);
            buffer = dictTable.makeRecord();
            select buffer where buffer.RecId == trackingStatus.ContextRecId;
            if (! buffer)
            {
                 info('You cannot go to the origin of the workflow instance. The record no longer exists or you do not have sufficient access.');
return;
            }
            dictTable.formRef();
            args.lookupRecord(buffer);

            args.name(dictTable.formRef());
            formRun = ClassFactory.formRunClass(args);
            formRun.init();
            formRun.run();
            formRun.detach();
        }
    }
}

This a very simple code to go to main Transaction Table, in above methods you can add your comment also to make it more user friendly, this a good practice to give error or empty records messages to End user to make your coding efficient and more user friendly.
-Harry

No comments:

Post a Comment

Thanks

Note: Only a member of this blog may post a comment.