Uncategorized

Importing Data From CSV File

static void upload(Args _args)
{
CommaTextIo file;
container record;
Itemid itemid;
PriceDiscTable p;
Price price;

;

file = new CommaTextIo(“C:\\Hbg & Est Prices 29 Nov 2013.csv”,’r’);
file.inFieldDelimiter(‘,’);

while (file.status() == IO_Status::Ok)
{
record = file.read();
itemid = conPeek(record, 1);
price = conPeek(record, 4);
if (itemid)
{
select forUpdate p
where p.ItemRelation == itemid
&& p.Agreement == ‘marketing’
&& p.AccountRelation == ”;

if (p)
{
ttsBegin;
p.Amount = price;
p.update();
ttsCommit;
}
else
{
select forUpdate p
where p.ItemRelation == itemid
&& p.Agreement == ‘HB01’;

if (p)
{
ttsBegin;
p.Amount = price;
p.update();
ttsCommit;
}
}
}}}

Standard
Dynamics Ax

Microsoft Dynamics Ax 2012:Simple use of Unit of Work

Overview

The main purpose to use UOW is to maintain the referential integrity. At a certain point of time application doesn’t want to be in a situation where violation of referential integrity occurs: for example for the records to be inserted and deleted; sequence should be maintain like Parent record should be inserted first and then the child record, and on deleting the record child should come first prior to parent. When we talk about programmatically maintain this, it is a quite big asks when we are dealing with more normalized data in Dynamics AX 2012.So to cater this “Microsoft Dynamics Ax 2012” provided the “UnitOfWork” programming concept which overcome this and maintain the referential integrity throughout the application.

Points of UOW:

  • It is basically a collection of operations(like CRUD) that are performed sequentially and as a Unit
  • “Application code establishes relation between data in memory, modifies data, registers the operation request with the UOW framework,and then request the UOW perform all the registered operation in the database as a unit.”
  • UOW always run on server

Simple Example:

In the below snapshot I have create two tables PurchHeader and PurchLines and a Foreign key relation on the child table PurchLines. You can also see the field for each table

UW1

I have also set the “CreateNavigationPropertyMethods” to Yes.

UW2

CreateNavigationPropertyMethods:

  • This property is only available for foreign key relation
  • When set to YES, it makes the kernel-generated methods on a table buffer to be created.
  • We can  use these methods to set, retrieve and navigate to the related table buffer through the specified relation.

As I mentioned above,UOW can always be used on server,so I have written a class to perform the operation,please also read the comments I have added.

UW3

After that when you open the PurchHeader and PurchLines table you will see the records have been created like

UW4

Standard
Dynamics Ax

creating new Dimension from existing entity

This blog is about creating new Dimension from existing entity so the dimension values can be used from database. like an existing available list of dimensions.

To set an entity to be dimensionable, create a view as directed below, Also, to integrate with the dimensions framework when deleting or renaming the natural key of the backing entity, you must write custom code on the backing table’s delete method, and also on either the update or renamePrimaryKey method. See CustTable for an example of the pattern these methods must follow

1. The view name must be DimAttribute[yourentityname]. For example, PSAActivityEstimates.
2. The view must contain a root data source named BackingEntity that points to your backing table to identify a surrogate key and natural key.
3. The view must contain the following fields named exactly as follows: • Key – Must point to the backing entity’s SK field. For example, an int64 RecId field. • Value – Must point to the backing entity’s NK field. For example, a str30 GrantId field. • Name – Must point to the source of an additional description for the entity. For example, a str60 Description field

List of dimensionable entities are also cached on both the client and server, so we have to execute the following line of code within a job in order to load the new dimension:

static void DimensionCacheclear(Args _args)
{
DimensionCache::clearAllScopes();
info(‘Scope is cleared’);
}

Standard
Dynamics Ax

Concurrent number of AOS for this application Exceeds the licensed number

While starting AX2009 instance, it fails and throws an error “Concurrent number of AOS for this application Exceeds the licensed number” in the system event log.
The customers license has plenty of users and multiple Axapta Object Servers.

1. The following error is received when trying to start 2nd AOS in a cluster installation:

“Concurrent number of AOS’ for this application exceeds the licensed number”

2. And this error is received when trying to start a 2Tier client from the same server after entering username and password:

“Cannot start Navision Axapta, as more users are running the system than the purchased rights allow”

CAUSE

Windows Registry setting

The customers license has plenty of users and multiple Axapta Object Servers.

1. The following error is received when trying to start 2nd AOS in a cluster installation:

“Concurrent number of AOS’ for this application exceeds the licensed number”

2. And this error is received when trying to start a 2Tier client from the same server after entering username and password:

“Cannot start Navision Axapta, as more users are running the system than the purchased rights allow”

CAUSE

Windows Registry setting

RESOLUTION 1

Changes made in the registry entry:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters

EnableOplocks REG_DWORD 0 or 1

Default: 1 (Enabled by Default)

Change it to 0.

Notes

  • This is not a license problem. One possible configuration to present the errors:

    The application is not installed on this server, but system directory in the configurations points to a hidden share on a server in the same domain. The user who is running AOS and 2Tier client is a domain user and has full access to the hidden share. The share could be opened in Explorer.

  • By default, if the registry key does not exist, the system considers that Oplocks is enabled. If the registry key does not exist, create the key by using a value that is set to 0 to disable the key.

RESOLUTION 1

Changes made in the registry entry:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters

EnableOplocks REG_DWORD 0 or 1

Default: 1 (Enabled by Default)

Change it to 0.

RESOLUTION 2
Open SQL Server Management Studio and select the Dynamics Ax database used for the instance.
Select New query and execute
SELECT * FROM dbo.SysServerSessions WHERE Status = 1;
Change the value of Status by using following query:
UPDATE  dbo.SysServerSessions SET Status = 0 WHERE Status = 1;
Now Server will Start..
Standard

The overall process I will describe will focus on the first stage of authoring and deploying the report from the developers perspective.

The basic steps

  • Create an AX Query
  • Create a new AX Reports Project and a new report in that project
  • Create a dataset in the report bound to that query
  • Create a design to report to render the dataset
  • Preview the design
  • Deploy the design to SSRS
  • View the report via IE
  • Save the Report project back into AX

The report I will create will be a simple un-formatted table of customers and customer IDs. If you want to format it then create a precision design and format it as you like.

 

SSRS Report

Dynamics AX 2009: Creating a simple SSRS Report

Image
Dynamics Ax

How to delete a label file in Dynamics AX 2012

Hi,
In this post we will look at how can we delete a label file in Dynamics AX 2012.Labels are no longer a file system like we had in 2009. We now have a new node in AOT – Label Files.
If you search in your application folder, you wont find the label file there.The application folder is located here.
“C:\Program Files\Microsoft Dynamics AX\60\Server\MicrosoftDynamicsAX\bin\ Application\ Appl\Standard”.
In Dynamics AX 2012, the label file is imported in your current model.
Now let us restart the AOS and see what happens. After restarting the AOS, go back to your application folder and try to find the label file again. This time the label file will be found.On every AOS restart, all label files will be copied to the application folder from the model store. So your label files are contained in your models but they are stored in your application folder as well.
Now let us try to delete the label file. Right click on your label file. Do you see a delete/remove option?
The answer is “No”. so how do we delete the label file then? Below is the method by which a label file can be deleted easily.

  1. To create a temporary model
  2. Move our label file to the temporary model
  3. Stop the AOS
  4. Delete the temporary model
  5. Start the AOS
Let ‘s do step by step.
Go to Tools -> Model management -> Create model.
Enter name as TmpModel. Press OK. You will recieve an info message saying “The model TmpModel was created successfully in layer usr.”
Right click on your label file and select “Move to model”.
Select the TmpModel checkbox and press OK.
Stop the AOS.
Open command prompt (Microsoft Dynamics AX 2012 Management Shell). We will be using the command line utility AXUTIL to delete the model.
Issue the following command in the command prompt.
AXUTIL delete /model:TmpModel
You will be prompted if you want to delete the model or not. Press Y
Start the AOS.
Delete the label file from your application folder as well.
When you open AX now, you will get a dialog saying that “Your model store has been modified.” This is normal because each time you perform an operation on a model, you will get this dialog. Depending on your operation, you should select one of the option. Since we just deleted a model which just had a label file, select Skip.
Open AOT and notice that the label file is deleted now.
Standard