AX2012 Use functions in queries and filters

These functions can be used in any query or filter. The functions need to put in brackets.

  • currentUserId()
  • currentEmployeeId()
  • currentBusinessRelationsAccount()
  • currentContactPersonId()
  • currentCustomerAccount()
  • currentVendorAccount()
  • 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)
  • currentStaticMasterPlan()
  • 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)

15

Advertisements

AX2012 Client access log

There is option to keep track of user activities in AX2012. AX2012 will flush all details about the forms that are opened or closed to the table SysClientAccessLog.

Details that can be found in this table:  what part of the form users are in, what events are triggered in the form, at what time, computer name, duration in milliseconds.

You can find the full post on the blog of the AX performance team.

AX2012 Copy usage data between users

The usage data is stored in the table SysLastValue. It is saved on userid, so it is easy to copy the data from one user to another.

Before you start the copy it is best that you delete the usage data from the user to which you want to copy.

static void copyUsageDataToAnotherUser(Args _args)
{
    SyslastValue        syslastOld, syslastNew;

    while select UserId from syslastNew
    where syslastNew.userId == 'AXuser1'
    {
        syslastNew.userId = 'AXuser2';
        syslastNew.Insert();
    }
}

AX2012 Access denied to field X in table X – Grant access to specific organizations individually

Access denied to field IBAN (BankIBAN) in table Vendor bank accounts. (Or any other field where the property AOSAuthorization is set to yes)

2017-01-12_18-24-47

Prerequisites

The solution provided is only applicable if you set up the “grant access to specific organizations individually”. The error does not occur when you choose “grant access to all organizations”.

Another prerequisite is that you use virtual companies and table collections.

2017-01-12_18-33-54

Solution

  1. When you close the form SysSecRoleAssignOM AX will save the details to which organization you gave that user/role combination access. This data will be stored in the table SecurityUserRoleCondition.
  2. The virtual companies are not included in table SecurityUserRoleCondition. You need to check when you close the screen if one of the organizations is included in a virtual company. If this is the case you can add the virtual company to.
  3. The two highlighted lines are added because they are the virtual companies.

1

Update incorrect Sales order status

In case you see that the sales order header or line status is wrong you can run a script that updates the line status based on the remaining qty and the header status based on the lowest status used in the sales order lines.

static void updateSOLineStatus(Args _args)
{
    SalesLine       salesLine;
    SalesStatus     oldSalesStatus;

    while select forUpdate salesLine
        where salesLine.SalesStatus == SalesStatus::Backorder
    {
        oldSalesStatus = salesLine.SalesStatus;
        salesline.setSalesStatus();
        ttsBegin;
        salesLine.update();
        ttsCommit;
        if (salesLine.SalesStatus != oldSalesStatus)
        {
            info(strfmt('SO %1 updated, from %2 to %3',salesLine.SalesId, oldSalesStatus, salesLine.SalesStatus));
        }
    }
}

Security Testing – Debugging when using restricted roles

Step 1:
Add the roles that you would like to test to your own user.
You also need to give yourself the role System administrator.
Step 2:
Open the development workspace.
Step 3:
Create a job and add following code.

static void nonAdminMode(Args _args)
{
    SecurityUtil::sysAdminMode(false);
}

Step 4:
Ctrl + W will open the workspace where you can simulate the issue.
At this moment you have reduced rights but you still have the possibility to debug.
Step 5:
When done testing & debugging close the session and run following job.

static void adminMode(Args _args)
{
    SecurityUtil::sysAdminMode(true);
}