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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Import or update default dimension from CSV (Comma Delimited) file with X++

(0) ShareShare
ReportReport
Posted on by

Hi ,

How do I insert new customer or update  dimensions or import default dimensions? 

I need job. 

plz suggest me 

thanks

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    DavidGunawan Profile Picture
    1,381 on at

    Hi Shub,

    To import data to AX 2012, there is out of the box function that you can use. Please look into data import export framework. You can refer link below for more details.

    ax.help.dynamics.com/.../walkthrough-import-data-from-a-csv-data-source-dixf-dmf

  • Community Member Profile Picture
    on at

    Hi David,

    Thanks for reply.. i need X++ code related that topic.

  • Suggested answer
    startax Profile Picture
    1,845 on at
  • Community Member Profile Picture
    on at

    Hi Dinkar,

    For customer dimension code not working ..showing Error "Financial dimension value  does not exist" have any idea about this .

    plz suggest me

    thanks

  • startax Profile Picture
    1,845 on at

    @shub

    can you share your code and csv screenshot ??

  • Community Member Profile Picture
    on at

    Hi Dinkar,

    static void CustomerDimension(Args _args)

    {

    CommaTextIO          csvFile;

    container                  readCon;

    counter                    icount;

    Dialog                      dialog;

    DialogField               dfFileName;

    FileName                 fileName;

    Struct                      struct;

    DimensionDefault      DimensionDefault;

    CustAccount  custAccount;//For vendor declare VendAccount

    CustTable      custTable; //Declared VendTable here

    container    ledgerDimension;

    int i;

    #File

    // create dialog for file selection

    dialog = new Dialog("Select  file to upload");

    dfFileName = dialog.addField(extendedTypeStr("FilenameOpen"));

    dialog.filenameLookupFilter(["All files", #AllFiles]);

    if (dialog.run())

    {

    csvFile = new CommaTextIo(dfFileName.value(), 'r');

    csvFile.inFieldDelimiter(',');

    readCon = csvFile.read();

    ttsBegin;

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

    {

    readCon = csvFile.read();

    if(readCon)

    {

    icount++;

    custAccount = conPeek(readCon,1);

    custTable = CustTable::find(custAccount,true);

    struct = new Struct();

    struct.add('BusinessUnit',conPeek(readCon,2)); //(DimensionName,Value)

    struct.add('CostCenter', conPeek(readCon,3));

    struct.add('Department', conPeek(readCon,4));

    ledgerDimension = conNull();

    ledgerDimension += struct.fields();

    for (i = 1; i <= struct.fields(); i++)

    {

    ledgerDimension += struct.fieldName(i);

    ledgerDimension += struct.valueIndex(i);

    }

    DimensionDefault = AxdDimensionUtil::getDimensionAttributeValueSetId(ledgerDimension);

    custTable.DefaultDimension = DimensionDefault;

    custTable.update();

    }

    }

    ttsCommit;

    }

    }

    CSV file formet

    Cust Account   BusinessUnit   CostCenter  Department

    DE-004             003                 010              024

  • Suggested answer
    startax Profile Picture
    1,845 on at

    @shub

    your code is looks fine i run the following code and it works

    static void SST_CustomerDimension(Args _args)

    {

       CommaTextIO                  csvFile;

       container                    readCon;

       counter                      icount;

       Dialog                       dialog;

       DialogField                  dfFileName;

       FileName                     fileName;

       Struct                       struct;

       DimensionDefault             DimensionDefault;

       CustAccount                  custAccount;//For vendor declare VendAccount

       CustTable                    custTable; //Declared VendTable here

       container                    ledgerDimension;

       int i;

                   icount++;

                   custAccount = "US-001";//conPeek(readCon,1);

                   custTable = CustTable::find(custAccount,true);

                   struct = new Struct();

                   struct.add('BusinessUnit',"003");//conPeek(readCon,2)); //(DimensionName,Value)

                   struct.add('CostCenter', "010");//conPeek(readCon,3));

                   struct.add('Department', "024");//conPeek(readCon,4));

                   ledgerDimension = conNull();

                   ledgerDimension += struct.fields();

                   for (i = 1; i <= struct.fields(); i++)

                   {

                       ledgerDimension += struct.fieldName(i);

                       ledgerDimension += struct.valueIndex(i);

                   }

                   DimensionDefault = AxdDimensionUtil::getDimensionAttributeValueSetId(ledgerDimension);

                   custTable.DefaultDimension = DimensionDefault;

                   custTable.update();

             }

    try to give single hard coded value as per given in this code. it will work  

  • Community Member Profile Picture
    on at

    Hi dinkar ,

    When i use same code update Dimension for csv file  is not working ..why this happening plzz Suggest

    Thanks

  • Verified answer
    startax Profile Picture
    1,845 on at

    @shub

    static void LeadProductCategory2(Args _args)

    {

       CommaTextIO                  csvFile;

       container                    readCon;

       counter                      icount;

       Dialog                       dialog;

       DialogField                  dialogField;

       FileName                     fileName;

       Struct                       struct;

       DimensionDefault             DimensionDefault;

       CustAccount                  custAccount;//For vendor declare VendAccount

       CustTable                    custTable; //Declared VendTable here

       container                    ledgerDimension;

       CommaIo                      commaIO;

       int i;

       #File

       #file

       dialog = new Dialog ("Select File");

       dialogField = dialog.addField(extendedTypeStr(FilenameOpen));

       dialog.filenameLookupFilter(["All Files",#Allfiles]);

       if (dialog.run())

       {

           fileName = dialogField.value();

       }

       commaIO = new CommaIo(filename,'r');

       if (commaIO)

       {

           ttsBegin;

           while (commaIO.status() == IO_Status::ok)

           {

               readCon = commaIO.read();

               if (readCon)

               {

                  icount++;

                   custAccount = conPeek(readCon,1);

                   custTable = CustTable::find(custAccount,true);

                   struct = new Struct();

                   struct.add('BusinessUnit',conPeek(readCon,2)); //(DimensionName,Value)

                   struct.add('CostCenter',conPeek(readCon,3));

                   struct.add('Department',conPeek(readCon,4));

                   ledgerDimension = conNull();

                   ledgerDimension += struct.fields();

                   for (i = 1; i <= struct.fields(); i++)

                   {

                       ledgerDimension += struct.fieldName(i);

                       ledgerDimension += struct.valueIndex(i);

                   }

                   DimensionDefault = AxdDimensionUtil::getDimensionAttributeValueSetId(ledgerDimension);

                   custTable.DefaultDimension = DimensionDefault;

                   custTable.update();

               }

           }

           ttsCommit;

       }

    }

    Use this code and put (custaccount,'003,'010,024) in your csv i am not using header in csv so remove header in csv. In csv if you not put (') before 0 then you get error. if your value is starting with 0 ex. 003 then it will be consider as 3 in csv .

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans