Search code examples
axaptax++dynamics-ax-2012-r3

How to get the Journal Number of an invoice when entering "Lines"?


I am trying to get the journal number (Red box) from the invoice journal. I have a button inside the Lines (blue box), however in order for it to work I need the Journal Number (red box) when I clicked the Lines (blue box).

enter image description here


Solution

  • Your Line form already have variable journalNum

    enter image description here

    So on your Lines form create parm method like this

    public LedgerJournalId parmJournalNum(LedgerJournalId _journalNum = journalNum) 
    { 
        journalNum = _journalNum; 
    
        return journalNum; 
    }
    

    And then in main method of your batch class you can get journal number using the following code

    if (classIdGet(args.caller()) == classNum(SysSetupFormRun)) 
    { 
        if (formHasMethod(args.caller(), identifierStr(parmJournalNum))) 
        { 
            journalNum = args.caller().parmJournalNum(); 
        } 
    }