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();
}
Related posts:

Resolving SSL/TLS Secure Channel Trust Errors in Dynamics 365 Finance and Operations

How to change a Bill of material (BOM) item on a production order
How to Set Up a Local Development Environment for D365 Finance and Operations Without Azure Costs
![Shopify Meets Dynamics 365 Finance and Operations: A Guide to Integration [Part 2]](https://www.cloudfronts.in/wp-content/uploads/2024/12/DALL·E-2024-12-14-12.29.44-A-professional-illustration-depicting-the-integration-between-Shopify-and-Dynamics-365-Finance-and-Operations.-The-image-shows-Shopify-on-one-side-wit-150x150.webp)
