Thursday, January 28, 2016

Writing a Test Job in AX7, Use of Like Operator and Bulk Update of Retail Screen Layout Button Properties

Hi All,

I aim to achieve three things with this post, i.e. to demonstrate

1. How we can execute a test job in AX7 which most of us already know in the good old AX 2012 as an AOT Node. 
2. Use of like operator in AX uses asterik '*' instead of '%' which we use in SQL
3. Changing Layouts of Retail Screens need not be tedious and time consuming by changing properties of each button manually.

So first things first, how do we write a test job in AX7? 
First step would be to create a test project, you can refer to this link for steps to create one

A job in AX7 is simply a public class and it must have a main method that provides the runnable code. The main method was required in AX 2012 too but there was no need for the class to have access specifier as public.  

So we create a new class in our project in AX by right clicking our project in the Solution Explorer and Clicking Add->New Item.

Here is some sample code that can be run to bulk update properties of buttons in the Retail Screen Layouts. Note the use of like Operator in this code.

class TestJob
    public static void Main(Args args)
        RetailButtonGridButtons retailButtonGridButtons;
        update_recordset retailButtonGridButtons
            setting BackColor=-65536,
        where retailButtonGridButtons.buttonGridId like '*ABC*';


On running the above code we get following screen on successful completion

So with this code you dont need to go to each Button Grid in the layout and change properties manually. So you can save your time and skip having to see the following screen multiple times 

-Hitesh Manglani

No comments:

Post a Comment