web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :

Custom query on dialog using SysOperationFramework in AX2012

Chaitanya Golla Profile Picture Chaitanya Golla 17,225

Hi,

We often come across a requirement to have AOT query along with dialog fields to be displayed on dialog using SysOperationFramework. In my example, I have chosen AOT query SalesUpdate along with dialog field ItemId to be displayed on the dialog. So created a controller class, contract class and service class(along with required exception handling mechanism).

CONTROLLER CLASS - CG_DataController

Method: ClassDeclaration

class CG_DataController extends SysOperationServiceController
{
}

Method : Main

public static void main(Args _args)
{
    CG_DataController dataController;

    dataController = new CG_DataController(classStr(CG_DataService),
                                           methodStr(CG_DataService, startOperation),
                                           SysOperationExecutionMode::Synchronous);

    dataController.parmDialogCaption("Sample");
    dataController.startOperation();
}

CONTRACT CLASS - CG_DataContract

Method : ClassDeclaration

[DataContractAttribute]
class CG_DataContract
{
    str             qrySalesUpdate;
    ItemId          itemId;
}

Method: parmItemId

[DataMemberAttribute]
public Itemid parmItemId(Itemid _itemId = itemId)
{
    itemId = _itemId;

    return itemId;
}

Method: parmQrySalesUpdate

[
    DataMemberAttribute,
    AifQueryTypeAttribute(identifierStr(_qrySalesUpdate), queryStr(SalesUpdate))
]
public str parmQrySalesUpdate(str _qrySalesUpdate = qrySalesUpdate)
{
    qrySalesUpdate = _qrySalesUpdate;

    return qrySalesUpdate;
}

SERVICE CLASS - CG_DataService

Method : ClassDeclaration

class CG_DataService extends SysOperationServiceBase
{
    // Contract Variables
    ItemId                  itemId ;
    str                     qrySalesUpdate;
}

Method: startOperation

[SysEntryPointAttribute]
public void startOperation(CG_DataContract _dataContract)
{
    System.Exception ex;
    #OCCRetryCount

    itemId         = _dataContract.parmItemId();
    qrySalesUpdate = _dataContract.parmQrySalesUpdate();

    try
    {
        this.processOperation();
    }

    catch (Exception::Deadlock)
    {
        retry;
    }

    catch (Exception::UpdateConflict)
    {
        if (appl.ttsLevel() == 0)
        {
            if (xSession::currentRetryCount() >= #RetryNum)
            {
                throw Exception::UpdateConflictNotRecovered;
            }
            else
            {
                retry;
            }
        }
        else
        {
            throw Exception::UpdateConflict;
        }
    }

    catch (Exception::Error)
    {
        error(strFmt("Error occured"));
        retry;
    }

    catch (Exception::CLRError)
    {
        ex = ClrInterop::getLastException();

        if (ex != null)
        {
            ex = ex.get_InnerException();
            if (ex != null)
            {
                error(strFmt("Error occured"));
            }
        }

        retry;
    }
}

Method: processOperation

private void processOperation()
{
    //TODO Implement business logic here
}

Input:

4431.SysOperation-_2D00_-Dialog.png

Regards,

Chaitanya Golla

Comments

*This post is locked for comments