Create Fixed Asset using X++ | CloudFronts

Create Fixed Asset using X++

In this blog article, we will see how we can create a Fixed Asset using code based on AssetGroupID.

Add below code in class to create a Fixed Asset,

public void createFixedAsset(AssetGroupId assetGroupId)
{
        AssetTable assetTable;
        NumberSeq numberSeq;
        assetTable.initValue();
        assetTable.assetGroup = AssetGroupId;

        //Initialize Number Seq for Asset Id
        numberSeq = assetTable.initAssetNumberSeq(assetTable.Assetgroup);
        AssetTable.AssetId = NumberSeq.num();        

        //Initialize other fields based on Asset Group                                      
        assetTable.initFromAssetGroupId(assetTable.Assetgroup);

        //Initialize name and Name Alias fron Item Id
        assetTable.Name = InventTable::find('ITM1104').itemName();
        assetTable.NameAlias = assetTable.Name;

        //Validate and Insert Fixed Asset. On insertion asset book is also created
        assetTable.validateWrite();
        assetTable.insert();
    }

Share Story :

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close