Thursday, August 14, 2014

Recently I was working on a project where I was calling into a class and I needed to verify the record that was coming in.  Here is how I did it:

public static void main(Args _args)
{
    MyClass                                myClass;
    RefRecId                                bankChequeTableRecId;
    FormDataSource                          formDataSource;
    ;

    myClass= MyClass::construct();
    if (_args != null && _args.dataSet() == tablenum(BankChequeTable) && _args.record().RecId != 0)
    {
        BankChequeTableRecId = _args.record().RecId;
        if (_args.record().IsFormDataSource() == true)
        {
            FormDataSource = _args.record().dataSource();
        }
    }
    if (BankChequeTableRecId != 0)
    {
        myClass.ToggleEditForAvidSync(BankChequeTableRecId);
    }
    if (formDataSource != null)
    {
        FormDataSource.research(true);
    }
}

Basically I am checking
1. _args has something
2. _args.dataSet() - Checking if this args is a BankChequeTable record
3. _args.record().RecId - Making sure there is a record in the args
4. Setting my RecId variable to the recid passed in by args.
5. _args.record().IsFormDataSource() - I want to know if this is a form data source and later one refresh that datasource.

I have needed this a lot so I thought I would post it up!

No comments:

Post a Comment