Ax 2012

Delete connection between not existing worker and existing user

Which stops you from assigning worker to the user ( this happens usually after migrations of data or something similar)

 

static void DelConBetweenNotExistWorkerandUser(Args _args)
{
    DirPersonUser         dirPersonUser;
    UserInfo                   userInfo;
    int                             counter;
    while select forUpdate dirPersonUser notExists join UserInfo
        where DirPersonUser.User == userinfo.id
    {
        info ( DirPerson::find(dirPersonUser.PersonParty).Name);
        dirPersonUser.delete();
    }
    info(int2str(counter));

}

Ax 2012

How to check weather all customers have nameAlias defined

I think one of the easier methods would be to run  this job, which will show number of all customers, and customer with Name Alias defined.

static void AmountOfCustomersWithNAmeAlias(Args _args)
{
    CustTable custtable;
    int counter1, counter2;

    while select CustTable
    {
        counter1++;
        if (CustTable.nameAlias())
        {
            counter2++;
        }
    }
   info (strFmt(“Counter1 %1, counter2 %2”,counter1, counter2));
}

Uncategorized

open task manager from cmd

sometimes when you use the Azure connection to AX, but you have no connection to the environment where AX is run, you can face situations when you have to terminate some kind of process.

For example you accidentally tried to copy all records of the really big table, and everything is hanging, and you can’t continue working because nothing is responsive.

If you have a connection to the cmd on the same environment you cans invoke task manager by entering taskmgr. and then you can terminate everything that you want 🙂

Uncategorized

How to know if user has a worker assigned to it

If your user has a worker then you will have connected records in following two table DirPersonUser  and hcmWorker.

In dirPersonUser table you can have a look at the user id, and using PersonParty field, try to find related record in the hcmWorker table,( field Person)

 

Or you can use the easy way ( by using hcmWorker.serid to worker method 🙂

Ax 2012

Check with Regexp if company name follows certain pattern

In my case I was looking for 2 U letters anywhere in the name or the short name of the company.

static void Job107(Args _args)
{
    TextBuffer companyShort = new TextBuffer();
    TextBuffer companyName = new TextBuffer();

    companyShort.setText(curext());
    companyShort.regularExpressions(true);
    companyName.setText(CompanyInfo::find().Name);
    companyName.regularExpressions(true);
    if (companyName.find(‘u.*u’) ||companyShort.find(‘u.*u’))
    {
        info(‘^.^’);
    }
}

Nice links to check regexp stuff : http://www.zytrax.com/tech/web/regex.htm 

And online editor to check if you were right: https://regex101.com/