Import Fixed Assets into AX

ahaagahaag Member Posts: 7
edited 2010-01-15 in Dynamics AX
Hello,

When importing fixed assets into Dynamics AX 2009 I have a problem with creating records for the AssetBook table.
After the AssetTable is created, apparently automatically an AssetBook record is also created. However this record cannot be found or even seen within the job I have created for importing the fixed assets.

The structure is as next:
static void ImportVa(Args _args)
{
// Variables
FileName filename = 'C:\\Temp\\VaTest1.csv';
CommaIO commaIO;
container readCon;
int i;
int level;

// declare columns within CSV-file
str column1; // FA-id
str column2; // FA-description
str column3; // FA-Groupd
str column4; // FA-Group description
.....

AssetTable assetTable;
AssetTrans assetTrans;
AssetBook assetBook;
;

// Initialisatie
commaIO = new CommaIO(filename, 'r');
commaIO.inFieldDelimiter(';'); // Delimiter

if (commaIO)
{

// Begin loop
while (commaIO.status() == IO_Status::Ok)
{
// Read line
readCon = commaIO.read();

// Overnemen inhoud
column1 = conPeek(readCon, 1);
column2 = conPeek(readCon, 2);
column3 = conPeek(readCon, 3);
.....

// Toon kolommen
if (column1 != '0' && column1 != '' )
{
// Check if FA already exists
assetTable = AssetTable::find(column1);

if (assetTable.RecId == 0)
{
ttsBegin;

// Create VA
assetTable.clear();
assetTable.initValue();
assetTable.AssetId = column1;
assetTable.Name = column2;
assetTable.NameAlias = column2;
assetTable.AssetGroup = column3;
assetTable.initFromAssetGroupId(column3);
assetTable.Quantity = 1;

assetTable.insert();

assetBook::Find(column1,'Tst-Akh',true); // Mark for update

if (assetBook.RecId == 0)
{
// Aanmaken Waardemodel
assetBook.clear();
assetBook.initValue();
assetBook.AssetId = column1;
assetBook.AssetGroup = column3;
assetBook.BookId = 'Tst-Akh';
....


// Zet status op open
assetBook.Status = AssetStatus::Open;

assetBook.insert();

}

ttsCommit;
}
}
}
}
}

Does anyone have an idea how to fix this?

Comments

  • jaestevanjaestevan Member Posts: 10
    assetBook::Find(column1,'Tst-Akh',true); // Mark for update

    You don't need this forUpdate flag in this case, but I don't think this will cause your problem, thought. I can't find any problem in your code, aparently, this is all ok :-k
    [Dynamics AX developer]
    http://www.jaestevan.com (AX Dev Blog)
    http://twitter.com/jaestevan (follow me!)
  • kranthikranthi Member Posts: 72
    I think you are missing one table here.

    table - AssetBookTable

    Try to insert into the above table also.
    Kranthi
Sign In or Register to comment.