web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Import Fixed Asset default dimensions

(0) ShareShare
ReportReport
Posted on by

Hello,

how can we import Fixed Assets default dimensions through Data Import Export Framework?

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Srini Ramidi Profile Picture
    2 on at
    RE: Import Fixed Asset default dimensions

    Hello,

    Do you want to populate DefaultDimension in AssetTable or AssetBook? any how both are not available using DIEF you have to add it by customization only.

  • Sangram Shinde Profile Picture
    2,114 on at
    RE: Import Fixed Asset default dimensions

    Hi Jackson,

    You have to customize Asset data entity to get dimensions in AX, you can refer 'generateDefaultDimension' method in some of DMF classes, e.g. you can get this method in DMFVendorEntityClass, before that you have to create one field in staging table to accept the dimension string from your source and then you can pass this value in your asset class method to generate the dimensions.

    You can refer below thread discussing about adding a custom field to entity-

    https://community.dynamics.com/ax/f/33/t/147569

    Thanks,

    Sangram.

    [View:https://community.dynamics.com/ax/f/33/t/147569:750:50]

  • David Tailor Profile Picture
    822 on at
    RE: Import Fixed Asset default dimensions

    Hi Sangram,

    how to modify Asset class:

    can you define step by step to add generate defaultdimension method to class?

  • David Tailor Profile Picture
    822 on at
    RE: Import Fixed Asset default dimensions

    Hello Professionals,

    any one have an idea about adding generatedefaultdimension method to DMFAssetEntity? As per Sangram, i referred to DMFVendorEntity, but didnt work.

    kindly send me code

    N.B.: i need this to be able to import Asset Master data with default dimension.

  • Suggested answer
    Sangram Shinde Profile Picture
    2,114 on at
    RE: Import Fixed Asset default dimensions

    Hi David,

    You can use below code to inset/update the dimensions for your Assets data in case of urgency as it is a CSV import code.

    But you can't use it in the DMFAssetEntity class as we have direct methods(AX Dimension methods) there instead of this lengthy code.

    Before that you have to know how to customize the standard data entity so that you can add your method and move ahead.

    Below code is working as I have tested it. Please check, hope this helps you.

    Thanks!

  • Suggested answer
    Sangram Shinde Profile Picture
    2,114 on at
    RE: Import Fixed Asset default dimensions

       static void DMF_Assets_Dimension_Import(Args _args)

       {

           Dialog                  dialog;

           DialogField          dfFileName;

           int                        noOfRecs = 0;

           CommaIO            csvFile;

           container             fileInCon,checkcon;

           counter                icount,inserted,check,updated,jcount,wcount;

           boolean               flag=0;

           FileName             fileName;

           AssetBook            assetBook;

           AssetId                 assetId;

           AssetBookId         assetBookId;

           Struct                    struct = new Struct();

           container               ledgerDimension;

           DimensionDefault        DimensionDefault,DefaultDim;

           String15                 DimVal1,DimVal2,DimVal3,DimVal4,DimVal5;              

           ;

           inserted    = 0;

           dialog      = new Dialog("Pick the file");

           dfFileName  = dialog.addField(extendedTypeStr(FileNameOpen));

           dialog.filenameLookupFilter(["CSV ","*.csv"]);

           if (dialog.run())

           {

               filename =  dfFileName.value();

           }

           csvFile     = new CommaIO(filename, 'r');

           if (csvFile)

           {

               while (csvFile.status() == IO_Status::OK)

               {

                   try

                   {

                       fileInCon = csvFile.read();

                       icount++;

                       if (fileInCon && icount>1)

                       {

                           flag = 0;

                           assetId             =  conPeek(fileInCon,1);

                           DimVal1             =  conPeek(fileInCon,2);

                           DimVal2             =  conPeek(fileInCon,3);

                           DimVal3             =  conPeek(fileInCon,4);

                           DimVal4             =  conPeek(fileInCon,5);

                           DimVal5             =  conPeek(fileInCon,6);

                           assetBookId         =  conPeek(fileInCon,7);

                           struct.add('BusinessUnit',DimVal1);

                           struct.add('CostCenter',DimVal2);

                           struct.add('Department',DimVal3);

                           struct.add('ItemGroup',DimVal4);

                           struct.add('Project',DimVal5);

                           ledgerDimension += struct.fields();

                           ledgerDimension += struct.fieldName(1);

                           ledgerDimension += struct.valueIndex(1);

                           ledgerDimension += struct.fieldName(2);

                           ledgerDimension += struct.valueIndex(2);

                           ledgerDimension += struct.fieldName(3);

                           ledgerDimension += struct.valueIndex(3);

                           ledgerDimension += struct.fieldName(4);

                           ledgerDimension += struct.valueIndex(4);

                           ledgerDimension += struct.fieldName(5);

                           ledgerDimension += struct.valueIndex(5);    

                              assetBook        =   AssetBook::find(assetId,assetBookId,true);

                              if(assetBook)

                                  {

                                       ttsBegin;

                                      // select forUpdate custTable;

                                       DimensionDefault = AxdDimensionUtil::getDimensionAttributeValueSetId(ledgerDimension);                                    

                                       assetBook.DefaultDimension = DimensionDefault;

                                       assetBook.update();

                                       updated++;

                                       info(strFmt("The Financial Dimension for AssetId %1 is updated",assetId));

                                       ttsCommit;

                                   }

                               else

                                  {

                                      //

                                      //Write insert logic here;

                                      //

                                   }

                       }//if

                   }//try

                   catch

                   {

                       info(strFmt("Error at line %1",icount));

                   }

               }//while

           }//if csv

               info(strfmt("%1 records updated out of %2",updated,icount-2));

       }//final

  • David Tailor Profile Picture
    822 on at
    RE: Import Fixed Asset default dimensions

    Thank you Sangram! it works well.

    however any blank dimension is giving validation error

    Note: in CSV file: comma separation with no value.

  • Suggested answer
    Sangram Shinde Profile Picture
    2,114 on at
    RE: Import Fixed Asset default dimensions

    Hi David,

    This job is only to update the dimensions for assets so if you don't have values for these what is the need of passing it through CSV.

    Any how you can write skip logic if values are blank in the dimension fields.

    Please mark the question as verified to close, if you got the answer.

    Thanks!

    Sangram

  • David Tailor Profile Picture
    822 on at
    RE: Import Fixed Asset default dimensions

    Hi Sangram,

    with respect to not passing values  through CSV if dimension value is blank, the following can answer your question:

    the excel file will have multiple rows to import, some FA will have let's say department value other will have department value blank.

    can you help me update the code you sent if dimension value is blank for some records.

    thank you

  • Suggested answer
    Sangram Shinde Profile Picture
    2,114 on at
    RE: Import Fixed Asset default dimensions

    Hi David,

    This will become lengthy code but it will work, you can check for some code optimization if possible for below code as I have added and tested it in hurry.

                           if(DimVal1!='')

                           {

                               struct.add('BusinessUnit',DimVal1);

                           }

                           if(DimVal2!='')

                           {

                               struct.add('CostCenter',DimVal2);

                           }

                           if(DimVal3!='')

                           {

                               struct.add('Department',DimVal3);                        

                           }

                           if(DimVal4!='')

                           {

                               struct.add('ItemGroup',DimVal4);

                           }

                           if(DimVal5!='')

                           {

                               struct.add('Project',DimVal5);

                           }                        

                           ledgerDimension += struct.fields();

                           if(DimVal1!='')

                           {                        

                               ledgerDimension += struct.fieldName(1);

                               ledgerDimension += struct.valueIndex(1);

                           }

                           if(DimVal2!='')

                           {

                               ledgerDimension += struct.fieldName(2);

                               ledgerDimension += struct.valueIndex(2);                        

                           }

                           if(DimVal3!='')

                           {                        

                               ledgerDimension += struct.fieldName(3);

                               ledgerDimension += struct.valueIndex(3);

                           }

                           if(DimVal4!='')

                           {                        

                               ledgerDimension += struct.fieldName(4);

                               ledgerDimension += struct.valueIndex(4);

                           }

                           if(DimVal5!='')

                           {                        

                               ledgerDimension += struct.fieldName(5);

                               ledgerDimension += struct.valueIndex(5);

                           }

    Replace this in above job, this will work surely.

    Thanks!

    Sangram.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Tocauer Profile Picture

Martin Tocauer 4

#2
Community Member Profile Picture

Community Member 2

#2
Nayyar Siddiqi Profile Picture

Nayyar Siddiqi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans