, I want to update the Calculation Group on all of my released products – because I forgot to load it through DIEF.
Now all of the records will be updated for you.
That wasn’t as hard as you probably thought was it.
- To create the script, just open up the AOT by pressing CTRL+D.
- And then press CTRL+SHIFT+P to open up the Projects explorer.
- Right-mouse-click on the Projects folder and select the Project option from the New sub-menu to create a new Project.
- This will create a new Project folder for you and if you click on it then you will be able to access the Properties window.
- Change the name on the Project so that it is a little more descriptive.
- Then right-mouse-click on the project and select the Open option to open up the project itself.
- When the Project is displayed, right-mouse-click on the header and select the New menu, and then the Job option.
- This will open up an X++ scripting pane for you to write your code within.
- Now is the dirty part. Create a variable that points to the table you want to update – in this case it’s the InventTable by adding this line of code: InventTable item;
- Then create a loop that will step through every record by typing this:
while select forUpdate item
{
}
- Then add your code to see if there is a record in the table to update:
if (item)
{
}
- Finally, add your code to update the record:
ttsBegin;
item.BOMCalcGroupId = “DEFAULT”;
item.update();
ttscommit;
-
The full code will look like this.static
void Job11(Args _args)
{
InventTable item;
while select forUpdate item
{
if (item)
{
ttsBegin;
item.BOMCalcGroupId = “DEFAULT”;
item.update();
ttscommit;
}
}
}
- To run the job, just click on the green play button in the menu bar.
Now all of the records will be updated for you.
That wasn’t as hard as you probably thought was it.
No comments:
Post a Comment