Category: AX 2012

  • Identify country specific functionality

    Add the following to SysCountryRegionCode::isLegalEntityInCountryRegion

    Idea by Kim Steffensen (Microsoft Escalation engineer)

    public static boolean isLegalEntityInCountryRegion(container _isoCountryCodes, selectableDataArea _selectableDataArea = curext())
    {
        #Define.DEBUG_ALL(true)                 //set true to get infolog for every country evaluated
        #Define.DEBUG_SINGLECOUNTRY(false)      //set true to get infolog when active country is evaluated
        int                             i;
        str                             callingPath;
        int                             line;
    
        if(#DEBUG_ALL || #DEBUG_SINGLECOUNTRY)
        {
            //initialize context
            callingPath = subStr(conPeek(xSession::xppCallStack(),3),4,999);
            line = conPeek(xSession::xppCallStack(),4);
        }
    
        if(#DEBUG_ALL && ! #DEBUG_SINGLECOUNTRY)
        {
            //print context of every country evaluated
            for(i=1; i <= conLen(_isoCountryCodes); i++)
            {
                info(strFmt("%1 %2 %3",conPeek(_isoCountryCodes,i),callingPath,line),"",SysInfoAction_Editor::newLineColumn(callingPath,line));
            }
        }
        if (conFind(_isoCountryCodes, SysCountryRegionCode::countryInfo(_selectableDataArea)))
        {
            if(#DEBUG_SINGLECOUNTRY)
            {
                //print context of active country evaluated
                info(strFmt("%1 %2 %3",SysCountryRegionCode::countryInfo(_selectableDataArea),callingPath,line),"",SysInfoAction_Editor::newLineColumn(callingPath,line));
            }
            return true;
        }
    
        return false;
    }
    
  • List of predefined AX 2012 Workflows

    CategoryWorkflowDescription
    Accounts payableVendor bank remittance journal workflowUse this type to create approval workflows for vendor bank remittance journals
    Accounts payableVendor disbursement journal workflowUse this type to create approval workflows for vendor disbursement journals
    Accounts payableVendor draw promissory note journal workflowUse this type to create approval workflows for vendor draw promissory note journals
    Accounts payableVendor invoice approval journal workflowUse this type to create approval workflows for vendor invoice approval journals
    Accounts payableVendor invoice journal workflowUse this type to create approval workflows for vendor invoice recording journals
    Accounts payableVendor invoice line workflowUse this type to create review workflows for vendor invoice lines
    Accounts payableVendor invoice register journal workflowUse this type to create approval workflows for vendor invoice register journals
    Accounts payableVendor invoice workflowUse this type to create review workflows for vendor invoices
    Accounts payableVendor redraw promissory note journal workflowUse this type to create approval workflows for vendor redraw promissory note journals
    Accounts payableVendor settle promissory note journal workflowUse this type to create approval workflows for vendor settle promissory note journals
    Accounts receivableCustomer bank remittance workflowUse this type to create approval workflows for customer bank remittance journals
    Accounts receivableCustomer draw bill of exchange workflowUse this type to create approval workflows for customer draw bill of exchange journals
    Accounts receivableCustomer free text invoice workflowUse this type to create approval workflows for free text invoices
    Accounts receivableCustomer payment workflowUse this type to create approval workflows for customer payment journals
    Accounts receivableCustomer protest bill of exchange workflowUse this type to create approval workflows for customer protest bill of exchange journals
    Accounts receivableCustomer recurring invoice workflowUse this type to create approval workflows for recurring invoices
    Accounts receivableCustomer redraw bill of exchange workflowUse this type to create approval workflows for customer redraw bill of exchange journals
    Accounts receivableCustomer settle bill of exchange workflowUse this type to create approval workflows for customer settle bill of exchange journals
    Advanced ledger entryAdvanced ledger entry workflowUse this type to create approval workflows for advance ledger entries
    BankBank reconciliation journal approval workflowUse this type to create approval workflows for Bank Reconciliation journals
    Budget planBudget plan workflowsUse this type to create and review workflows for budget plans
    Budget register entriesBudget account entry workflowUse this type to create review workflows for budget account entries
    Budget register entriesBudget register entry workflowUse this type to create review workflows for budget register entries
    Budget register entriesCommitments approvalUse this template to create approval workflows for commitment documents
    Case managementCase management workflowUse this type to create a workflow for cases
    Case managementDocument handlingWorkflow type for document handling
    Fixed assetsLedger fixed assets budget journal workflowUse this type to create approval workflows for fixed asset budget journals
    Fixed assetsLedger post fixed assets journal workflowUse this type to create approval workflows for post fixed asset journals
    General ledgerLedger allocations journal workflowUse this type to create approval workflows for allocation journals
    General ledgerLedger daily journal workflowUse this type to create approval workflows for daily journals
    General ledgerLedger eliminations journal workflowUse this type to create approval workflows for eliminations journal
    Procurement and sourcingCatalog import approvalUse this type to create review workflows for imported catalogs
    Procurement and sourcingCatalog import product approvalUse this type to create review workflows for imported catalog products
    Procurement and sourcingDelivery due date notification workflowUse this type to create delivery due date notification workflows for unconfirmed product receipts
    Procurement and sourcingInvoice received notification workflowUse this type to create invoice received notification workflows for unconfirmed product receipts
    Procurement and sourcingProduct receipt failed notification workflowUse this type to create notifications workflows for failed product receipts
    Procurement and sourcingPurchase order line workflowUse this type to create review- and approval workflows for purchase order lines
    Procurement and sourcingPurchase order workflowUse this type to create review- and approval workflows for purchase orders
    Procurement and sourcingPurchase requisition line reviewUse this type to create review workflows for purchase requisition lines
    Procurement and sourcingPurchase requisition reviewUse this type to create review workflows for purchase requisitions
    Procurement and sourcingUnconfirmed product receipt rejection notification workflowUse this type to create notification workflows for rejected unconfirmed product receipts
    ProjectReview budget revision workflowUse this type to review a budget revision
    ProjectReview original budget workflowUse this type to review an original budget
    ProjectReview project invoice proposalsUse this type to review project invoice proposals
    ProjectReview project quotationsUse this type to review project quotations
    Purchase agreement approval workflowPurchase agreement approval workflowUse this type to create approval workflows for purchase agreements
    Retail catalog workflow categoryRetail catalog approval workflowRetail catalog approval workflow type
    Signing limitsSigning limits workflowUse this template to create a workflow for review of signing limit requests
    Time and attendanceTime and attendance days total workflowUse this type to create approval workflows for time and attendance days total records
    Time and attendanceTime and attendance journal registration workflowUse this type to create approval workflows for time and attendance journal registration records
    TimesheetReview timesheet line workflowUse this type to review a timesheet line
    TimesheetReview timesheet workflowUse this type to review a timesheet
    Travel and expenseCash advance requestUse this type to create approval workflows for cash advance requests
    Travel and expenseDispute managementUse this type to create workflows for credit card dispute management
    Travel and expenseExpense line itemUse this type to create line item approvals for expense reports
    Travel and expenseExpense line item auto postingUse this type to create line item automatic posting workflows for expense reports
    Travel and expenseExpense reportUse this type to create document approvals for expense reports
    Travel and expenseExpense report auto postingUse this type to create document automatic posting workflows for expense reports
    Travel and expenseTravel requisitionUse this type to create approval workflows for travel requisitions
    Travel and expenseVAT tax recoveryUse this type to create approval workflows for VAT tax recovery
    User managementInactivate user request workflowUse this type to create user inactivation workflows for inactivate user requests
    User managementUser request workflowUse this type to create user provisioning workflows for user requests
    Vendor request managementVendor add application workflowUse this type to create approval workflows for vendor add application requests
    Vendor request managementVendor add justification workflowUse this type to create approval workflows for vendor add justification requests
    Vendor request managementVendor category application workflowUse this type to create approval workflows for vendor category application requests
    Vendor request managementVendor category justification workflowUse this type to create approval workflows for vendor category justification requests
    Vendor request managementVendor status change request workflowUse this type to create approval workflows for vendor status change requests

    This list was exported using the following job:

    static void workFlowDescription(Args _args)
     {
        #AOT
        Treenode                workflowTypesNode, workFlowNode;
        int                     i;
        int                     nodeCount;
        str                     workflowName;
        SysDictWorkflowType     sysDictWorkflowType;
        SysDictWorkflowCategory sysDictWorkflowCategory;
        ;
    
        workflowTypesNode = treenode::findNode(#WorkflowTypesPath);
        nodeCount = workflowTypesNode.AOTchildNodeCount();
    
        workFlowNode = workflowTypesNode.AOTfirstChild();
        for (i=1; i<=nodeCount; ++i)
        {
            workflowName = workFlowNode.AOTgetProperty("Name");
            try
            {
                sysDictWorkflowType = SysDictWorkflowType::newTypeName(workflowName);
                sysDictWorkflowCategory = new SysDictWorkflowCategory(sysDictWorkflowType.category());
                info(sysDictWorkflowCategory.label() + ";"
                + sysDictWorkflowType.label() + ";"
                + sysDictWorkflowType.help());
            }
            catch ( Exception::Error)
            {
                exceptionTextFallThrough();
            }
            workFlowNode = workFlowNode.AOTnextSibling();
        }
    }
    
  • AX 2012 CU7 – Send documents to e-mail addresses defined on the customer.

    Probably every AX consultancy has programmed a module to send customer documents by email using addresses defined on the customer. With CU7 you can finally can do this in Standard AX:

    Define a primary e-mail on the customer
    clip_image002

    In the print dialog select “Customer primary contact”
    clip_image004

    Result: The e-mail is sent to the primary e-mail address defined on the customer.

    The settings are now saved in the print destinations and do not need to be changed anymore. When the primary e-mail address is changed, the next e-mail will automatically be sent to the new address.

    Even better, once the print settings have been saved, all sales orders will pick up their respective customer emails without further settings needed.

    Follow the instructions here http://blogs.msdn.com/b/axsupport/archive/2013/02/05/emailing-customer-invoices-from-a-batch.aspx, you will be able to automatically send you confirmations and invoices by email using email addresses defined on the customer.

    Even better: Define e-mail addresses for different documents by applying customizable purposes:
    clip_image006

    Select purpose in the print dialog:

    clip_image008

    Final Note: If the defined e-mail is missing you will get the following error.
    clip_image002[5]

  • Pattern: Job to delete many records

    Pattern for efficient (i.e. use transaction for multiple deletes and use doDelete), stable (i.e. don’t make one huge transaction but commit and restart transaction periodically) and verbose (count down the number of remaining records) job to delete many records in a table.

    static void deleteJob(Args _args)
    {
        #define.TABLE(myTable)         //set
        #define.CONDITION(true)        //set
        #define.TRANSACTIONSIZE(100)   //set
        #TABLE #TABLE;
        int i = 1;
        ;
        while (i>0)
        {
            i=0;
            info(strfmt("%1",(select count(RecId) from #TABLE where #CONDITION).RecId));
            infolog.viewUpdate();
            ttsbegin;
            while select forupdate #TABLE where #CONDITION
            {
                #TABLE .dodelete();
                i++;
                if(i>=#TRANSACTIONSIZE)
                    break;
            }
            ttscommit;
        }
    }
    
  • Functions to use in Queries, Filters

    Joris on Dynamics AX Musings wrote this Blog Entry: Custom Query Range Functions using SysQueryRangeUtil

    The following functions can be used in any query or filter. Note that the functions are case sensitive and need to be put in brackets e.g. (currentUserId()).

     

    Current user (or roles thereof)

    • currentUserId()
    • currentEmployeeId()
    • currentBusinessRelationsAccount()
    • currentContactPersonId()
    • currentCustomerAccount()
    • currentVendorAccount()

    Dates (all but dateRange are relate to the current date and time)

      • currentSessionDate()
      • currentSessionDateTime()

      • day(int relativeDays = 0)
      • dayRange(int relativeDaysFrom = 0, int relativeDaysTo = 0)
      • greaterThanDate(int relativeDays = 0)
      • lessThanDate(int relativeDays = 0)
      • monthRange(int relativeMonthsFrom = 0, int relativeMonthsTo = 0)
      • yearRange(int relativeYearsFrom = 0, int relativeYearsTo = 0)

    • dateRange(date startDate, date endDate)

    Constants

    • currentStaticMasterPlan()

    AX2012 only

      • currentDate()
      • currentLanguageId()
      • currentUserLanguage();
      • currentWorker()
      • currentWorkerRecId()
      • currentLegalEntity()
      • currentParty()
      • advancedLedgerEntryCurrentUserFilter(boolean _createdBy)
      • advancedLedgerEntryTxtOpenDraftAll(anytype _advancedLedgerEntryTransactionStatus)
      • currentRoleHasAccessToPrivate(boolean _useCache = true)
      • currentStaticMasterPlanVersion()
      • dateRange(date startDate, date endDate)

      • lessThanUtcDate(int relativeDays = 0)
      • lessThanUtcNow()

      • greaterThanUtcDate(int relativeDays = 0)
      • greaterThanUtcNow()

    • documentStatusPurchOrderOrGreater()
    • getActiveMasterPlanVersionByPlanId(ReqPlanId _planId)
    • isDirAddressPolicyOff()
    • isPrivate()
    • pmfInventTableIsBOM()
    • pmfInventTableIsBOMFormula()
    • projActiveAll(ProjActiveAll _projActiveAll)
    • projActiveAllWIPEliminated(anytype _ProjTableActiveAll)
    • projLevels(ProjLevels _projLevels)
    • projPostedTransType(ProjPostTransViewType _projPostedTransViewType)
    • projUnpostedTransType(ProjUnpostedTransViewType _projUnpostedTransViewType)
    • salesQuotationTemplateGroupFilter(SalesQuotationFilter _salesQuotationFilter)
    • salesQuotationTypeListPageFilter(SalesQuotationTypeListPage _salesQuotationTypeListPage)
    • sessionGuid()
    • workflowDelegationFilter(WorkflowDelegationView _filter)

    As you see AX 2012 has many more predefined special ranges, many of which are not very self explanatory, as they are not really intended for general use, but are used in the filters of the pre-filtered list pages.

    And remember: as Joris showed, you can easily extend the list.

  • Debugging AX2012

    Yes, CIL code can be debugged in visual studio, but it’s much easer to just disable CIL and use the Morph-X debugger:

    File > Tools > Options > Development > Execute business operations in CIL = “No”

    HS7ClipImage_51ecf366
  • Quick fix for posting definitions error

    Error Message

    The source document cannot be processed until you assign a posting definitions to the source document in the Transaction posting definition form.

    Quick fix

    Simply disable posting definitions here: General ledger >> Setup >> General ledger parameters

    HS7ClipImage_51d16594