Thursday 23 January 2020

CONTRACT CLASS IN SYSOPERATION D365 CODE X++ DYNAMICS AX

Hi,
In the below post you will see the sysoperation framework contract class which can be used to run the class form the contract class.

/// <summary>
///myclass contract
/// </summary>
[DataContractAttribute]
class MyClassContract
{
    str                      packedQuery;
    ItemId itemid;
    InventLocationId locationid;
    InventSiteId siteId;
    InventQty qty;

    [DataMemberAttribute,
    AifQueryTypeAttribute('_packedQuery', querystr(MyClassQuery))
    ]
    public str parmQuery(str _packedQuery = packedQuery)
    {
        packedQuery = _packedQuery;
        return packedQuery;
    }

    public Query getQuery()
    {
        return new Query(SysOperationHelper::base64Decode(packedQuery));
    }

    public void setQuery(Query _query)
    {
        packedQuery = SysOperationHelper::base64Encode(_query.pack());
    }

    [DataMemberAttribute,  SysOperationControlVisibilityAttribute(false)]
    public ItemId parmItemid(ItemId _itemid = itemId)
    {
        itemid = _itemid;
        return itemid;
    }

    [DataMemberAttribute,  SysOperationControlVisibilityAttribute(false)]
    public InventSiteId parmSiteId(InventSiteId _siteId = siteId)
    {
        siteId = _siteId;
        return siteId;
    }

    [DataMemberAttribute,  SysOperationControlVisibilityAttribute(false)]
    public InventlocationId parmLocationId(InventlocationId _locationid = locationid)
    {
        locationid = _locationid;
        return locationid;
    }

}

********************************************************************************
for validation use below class
/// <summary>
/// desctiption
/// </summary>
[DataContractAttribute]
public class MyClassContract implements SysOperationValidatable
{
    str         query;
    TransDate   fromDate;
    TransDate   toDate;
    DataAreaId fromDateany,toDateany;
 
   [
        DataMemberAttribute,
        SysOperationLabelAttribute('@Label'),
        SysOperationDisplayOrderAttribute('1')
    ]
    public TransDate parmFromDate(TransDate _FromDate = FromDate)
    {
        FromDate = _FromDate;
        return FromDate;
    }
 
    [
        DataMemberAttribute,
        SysOperationLabelAttribute('@Label'),
        SysOperationDisplayOrderAttribute('2')
    ]
    public TransDate parmToDate(TransDate _toDate = toDate)
    {
        toDate = _toDate;
        return toDate;
    }

    [DataMemberAttribute, AifQueryTypeAttribute('_query', querystr(MyClassQuery))]
    public str parmQuery(str _query = query)
    {
        query = _query;
        return query;
    }

    public Query getQuery()
    {
        return new Query(SysOperationHelper::base64Decode(query));
    }

    public void setQuery(Query _query)
    {
        query = SysOperationHelper::base64Encode(_query.pack());
    }

    public static MyClassContract construct()
    {
        return new MyClassContract();
    }

    public boolean validate()
    {
        boolean ret = true;

        if (!this.parmFromDate() || !this.parmToDate())
        {
            ret = checkFailed("@@Label");
      }

        return ret;
    }

    protected void new()
    {
    }

}

Thanks!!!!!!!!!!!!!!!!11111

3 comments:

  1. Can nicely write on similar topics! Welcome to here you'll find out how it should look. contract management software

    ReplyDelete
  2. Great post i must say and thanks for the information. Education is definitely a sticky subject. However, is still among the leading topics of our time. I appreciate your post and look forward to more. ContractSafe

    ReplyDelete

AZURE INTERVIEW QUESTIONS AND ANSWERS

AZURE INTERVIEW QUESTIONS AND ANSWERES 2021 2. What is cloud computing? Explanation:  It is the use of servers on the internet to “store...