Monday, 16 December 2013

Contract Class in ax 2012 SSRS Reports

Contract :
[
    DataContractAttribute
,    SysOperationGroupAttribute('Date', "Period", '1')
,SysOperationContractProcessingAttribute(classStr(ICDOCCollectorInformationUIBuilder))
]
public class ICDOCCollectorInformationContract //implements SysOperationValidatable
{
    boolean     ExecuteZero;
    FromDate    fromDate;
    ToDate      toDate;
    Name        dimension;
    AgentCode   agentCode;
    Branch      Branch;
}


[
    DataMemberAttribute('FromDate'),
    //SysOperationLabelAttribute(literalstr("@SYS68117")),
    SysOperationGroupMemberAttribute('Date'),
    //SysOperationGroupMemberAttribute('Bid Submission Date'),
    SysOperationDisplayOrderAttribute('1')
]
public FromDate parmFromDate(FromDate _fromDate = fromDate)
{
    fromDate = _fromDate;
    return fromDate;
}

[
    DataMemberAttribute('ToDate'),
    //SysOperationLabelAttribute(literalstr("@SYS68118")),
    SysOperationGroupMemberAttribute('Date'),
    //SysOperationGroupMemberAttribute('Bid Submission Date'),
    SysOperationDisplayOrderAttribute('2')
]
public ToDate parmToDate(ToDate _toDate = toDate)
{
    toDate = _toDate;
    return toDate;
}


public boolean validate()
{
    boolean isValid = true;

    if(!fromDate)
    {
        isValid = checkFailed("@SYS97591");
    }

    if(!toDate)
    {
        isValid = checkFailed("@SYS97592");
    }

    if(fromDate && toDate)
    {
        if(fromDate > toDate)
        {
            isValid = checkFailed("@SYS120590");
        }
    }

    return isValid;
}

Note: if we extend the class with " implements SysOperationValidatable" then we have to write the validate method compursary


1 comment:

  1. hi

    if (fromDate) will it not return an error ? because if is normally used to compare with something
    (Viz( if(fromDate = "01/05/2016) because if(fromdate) is returning a datetype and not Boolean with if expects. Kindly clarify

    Thanks in Advance

    ReplyDelete