Tuesday 24 September 2024

AX365 / AX 2012 Data contract class with full attributes labels , groups and sorting

 [DataContractAttribute,

SysOperationGroupAttribute("ItemID", "Item number", "1"), //SysOperationGroupAttribute("AccountsGroup", "@SYS313802", "1", FormArrangeMethod::Vertical),

  SysOperationGroupAttribute("DateRange", "Date Range", "2"),

  SysOperationGroupAttribute("Dimensions", "Inventory diemsnions", "3")

]

 public class SHItemCardReportContract

{

    Itemid itemId;

    FromDate fromDate;

    ToDate toDate;

    InventLocationId inventLocationId;

    EcoResItemColorName ecoResItemColorName;

    EcoResItemSizeName ecoResItemSizeName;


    [DataMemberAttribute("Itemid"),

     SysOperationLabelAttribute("@SYS12836"),

     SysOperationGroupMemberAttribute("ItemID"),

     SysOperationDisplayOrderAttribute('1')

        ]

    public Itemid parmItemid(Itemid val = itemId)

    {

        itemId = val;

        return itemId;

    }


    [DataMemberAttribute("FromDate"),

     SysOperationLabelAttribute("@SYS5209"),

     SysOperationGroupMemberAttribute("DateRange"),

     SysOperationDisplayOrderAttribute('1')

        ]

    public FromDate parmFromDate(FromDate val = fromDate)

    {

        fromDate = val;

        return fromDate;

    }


    [DataMemberAttribute("ToDate"),

     SysOperationLabelAttribute("@SYS14656"),

     SysOperationGroupMemberAttribute("DateRange"),

     SysOperationDisplayOrderAttribute('2')

        ]

    public ToDate parmToDate(ToDate val = toDate)

    {

        toDate = val;

        return toDate;

    }


    [DataMemberAttribute("InventLocationId"),

      SysOperationLabelAttribute("@SYS6437"),

     SysOperationGroupMemberAttribute("Dimensions"),

     SysOperationDisplayOrderAttribute('1')

        ]

    public InventLocationId parmInventLocationId(InventLocationId val = inventLocationId)

    {

        inventLocationId = val;

        return inventLocationId;

    }


    [DataMemberAttribute("EcoResItemColorName"),

     SysOperationLabelAttribute("@SYS73726"),

     SysOperationGroupMemberAttribute("Dimensions"),

     SysOperationDisplayOrderAttribute('2')

        

        ]

    public EcoResItemColorName parmEcoResItemColorName(EcoResItemColorName val = ecoResItemColorName)

    {

        ecoResItemColorName = val;

        return ecoResItemColorName;

    }


    [DataMemberAttribute("EcoResItemSizeName"),

     SysOperationLabelAttribute("@SYS73727"),

     SysOperationGroupMemberAttribute("Dimensions"),

     SysOperationDisplayOrderAttribute('3')

        ]

    public EcoResItemSizeName parmEcoResItemSizeName(EcoResItemSizeName val = ecoResItemSizeName)

    {

        ecoResItemSizeName = val;

        return ecoResItemSizeName;

    }


}

Sunday 22 September 2024

AX365 X++ Get the current Workflow Step name

 Here is a method to get the current workflow step name using X++ just pass the table rec id which is applied to the workflow and you can get the step name


public static str getCurrentStepName(RecId _Id)

{

    WorkflowTrackingTable _WorkflowTrackingTable;

    WorkflowTrackingStatusTable _WorkflowTrackingStatusTable;

    WorkflowElementTable _WorkflowElementTable;

    


    select firstonly _WorkflowTrackingTable

        order CreatedDateTime desc

       join _WorkflowTrackingStatusTable

        where _WorkflowTrackingStatusTable.RecId == _WorkflowTrackingTable.WorkflowTrackingStatusTable

        join _WorkflowElementTable

        where _WorkflowElementTable.RecId == _WorkflowTrackingTable.WorkflowElementTable

       && _WorkflowTrackingTable.TrackingType == WorkflowTrackingType::Creation

       && _WorkflowTrackingTable.TrackingContext == WorkflowTrackingContext::Step

        && _WorkflowTrackingStatusTable.ContextRecId == _Id

        && _WorkflowTrackingStatusTable.ContextTableId == tableNum(InventTable)

       ;

                

   

    return _WorkflowElementTable.ElementName;

}