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;

}

Wednesday 8 May 2024

AX365 X++ use SysOperationSandbox class

  container _Xyz=[_InventJournalTable.JournalId];

    
            SysOperationSandbox::callStaticMethod(classNum(AtosCountJournalUpdateDim),staticMethodStr(AtosCountJournalUpdateDim,RunmyProcess),_Xyz,'Count Record in process', 'Operation completed');
 
            fds.reread();
            fds.refresh();
            fds.research(true);
==============================================================================

 class AtosCountJournalUpdateDim
{

 Public static void RunmyProcess(Container _C)
    {
 _InventJournalId = conpeek(_C,1);
}
}

Saturday 20 April 2024

AX365 Workflow bar is not showing in normal steps

 public static class KPFVendTableForm_Extension

{

    [FormEventHandler(formStr(VendTable), FormEventType::Initializing)]

    public static void SalesTableListPage_OnInitializing(xFormRun sender, FormEventArgs e)

    {

        FormRun                VendTableListPage         = sender;

        FormBuildDesign VendTableListPageDesign = VendTableListPage.form().design();


        VendTableListPageDesign.workflowEnabled(true);

        VendTableListPageDesign.workflowDatasource(tableStr(VendTable));

        VendTableListPageDesign.workflowType(workflowTypeStr(KPFVendorWorkflowType));

    }


    [PostHandlerFor(classStr(FormDataUtil), staticMethodStr(FormDataUtil, canSubmitToWorkflow))]

    public static void FormDataUtil_Post_canSubmitToWorkflow(XppPrePostArgs args)

    {

        Common             record               = args.getArg(identifierStr(_record));

        VendTable          salesTable           = record as VendTable;

        boolean            ret                  = args.getReturnValue();


        if (record.TableId == tableNum(VendTable))

        {

            if (salesTable.VendorStatus == KPF_ProductWorkflowBaseEnum::Draft)

            {

                ret = boolean::true;

            }

            else

            {

                ret = boolean::false;

            }

        }

        args.setReturnValue(ret);

    }


    [PostHandlerFor(formStr(VendTable), formMethodStr(VendTable, canSubmitToWorkflow))]

    public static void SalesTable_Post_canSubmitToWorkflow(XppPrePostArgs args)

    {

        FormRun salesTableDetails = args.getThis();

        formDataSource salesTableDS    = salesTableDetails.dataHelper().FindDataSource(formDataSourceStr(VendTable, VendTable));

        VendTable salesTable    = salesTableDS.cursor();

        boolean ret    = args.getReturnValue();

        if (salesTable.VendorStatus == KPF_ProductWorkflowBaseEnum::Draft)

        {

            ret = true;

        }

        else

        {

            ret = false;

        }

        args.setReturnValue(ret);

        salesTableDetails.design().controlName('WorkflowActionBarButtonGroup').visible(true);

    }


}

AX365 X++ run code after posting a sales order

 [ExtensionOf(ClassStr(SalesInvoiceJournalPost))]

final class SalesInvoiceJournalPost_Extension

{

   protected void endPost()

   {

       next endPost();

       Info(strFmt("SalesId : %1",custInvoicejour.salesId));

   }

}

Monday 25 March 2024

𝐆𝐢𝐭𝐇𝐮𝐛 𝐂𝐡𝐞𝐚𝐭𝐬𝐡𝐞𝐞𝐭

 1. 𝐑𝐞𝐩𝐨𝐬𝐢𝐭𝐨𝐫𝐲 𝐁𝐚𝐬𝐢𝐜𝐬:

- Clone a Repository:
Command:
git clone <repository_url>


- Initialize a Repository:
Command:
git init


2. 𝐖𝐨𝐫𝐤𝐢𝐧𝐠 𝐰𝐢𝐭𝐡 𝐁𝐫𝐚𝐧𝐜𝐡𝐞𝐬:
- Create a New Branch:
Command:
git branch <branch_name>


- Switch to a Branch:
Command:
git checkout <branch_name>


- Create and Switch to a New Branch:
Command:
git checkout -b <new_branch_name>


- List Branches:
Command:
git branch

-delete remote branch 
git push origin --delete MainProject

3. 𝐂𝐨𝐦𝐦𝐢𝐭𝐭𝐢𝐧𝐠 𝐂𝐡𝐚𝐧𝐠𝐞𝐬:
- Stage Changes:
Command:
git add <file_name>


- Stage All Changes:
Command:
git add .


- Commit Changes:
Command:
git commit -m "Commit message"


4. 𝐏𝐮𝐥𝐥𝐢𝐧𝐠 𝐚𝐧𝐝 𝐏𝐮𝐬𝐡𝐢𝐧𝐠:
- Pull Changes from Remote:
Command:
git pull origin <branch_name>


- Push Changes to Remote:
Command:
git push origin <branch_name>


5. 𝐌𝐞𝐫𝐠𝐢𝐧𝐠 𝐂𝐡𝐚𝐧𝐠𝐞𝐬:
- Merge Branch into Current Branch:
Command:
git merge <branch_name>


6. 𝐖𝐨𝐫𝐤𝐢𝐧𝐠 𝐰𝐢𝐭𝐡 𝐑𝐞𝐦𝐨𝐭𝐞𝐬:
- Add a Remote Repository:
Command:
git remote add <remote_name> <repository_url>


- List Remote Repositories:
Command:
git remote -v


7. 𝐇𝐚𝐧𝐝𝐥𝐢𝐧𝐠 𝐂𝐨𝐧𝐟𝐥𝐢𝐜𝐭𝐬:
- Check for Conflicts:
Command:
git diff


- Resolve Conflicts and Continue Merge:
Command:
git add <file_name>
git merge --continue


8. 𝐆𝐢𝐭𝐇𝐮𝐛 𝐀𝐜𝐭𝐢𝐨𝐧𝐬:
- Workflow Syntax Checking:
Command:
git pull origin <branch_name>
git push origin <branch_name>


9. 𝐌𝐢𝐬𝐜𝐞𝐥𝐥𝐚𝐧𝐞𝐨𝐮𝐬:
- Check Git Status:
Command:
git status


- View Commit History:
Command:
git log


- Ignore Files (Add to `.gitignore`):
Command:
echo "<file_name>" >> .gitignore