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 :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Reading Enum From Excelsheet

(0) ShareShare
ReportReport
Posted on by 454

I am having a Table named as M_Account . This table has 4 Fields. the Fourth field is a Enum Field named as Resource Category . In a Excel Sheet There are Four fields as same as M_Account Table. I have to Read the Enum Field from excel sheet and i have to Insert that Enum Data into the M_Account Table . 

_rescat = str2enum(cells.item(row,4).value().bStr());

I am facing an error wrong number of arguments has been specified for the method . 

Please give the solution for me and i am new to AX. 

Thanks in Advance,

Ram.

I have the same question (0)
  • André Arnaud de Calavon Profile Picture
    301,109 Super User 2025 Season 2 on at

    Hi Ram,

    The data import/export framework is able to read Excel files and do the import for you which also takes enum fields in consideration. Have you had a look at this framework? Or what is the reason that you started developing something with x++ coding? What is the business process here?

  • Suggested answer
    nmaenpaa Profile Picture
    101,162 Moderator on at

    I suggest you use standard data entities, then you don't have to think about such things at all.

    Anyway, if you want to convert string to enum, please continue reading.

    When you type "str2Enum(" you see the tooltip which says you must provide two parameters: enum type and the text. This is very important information for a developer so it's good to get familiar with utilizing such documentation that is provided you during development.

    Having to provide the enum type is quite obvious, because otherwise there would not be enough information for the conversion. Many enums might have options that have the same name. So how would the system know which enum it is, unless you tell it?

    For example, to convert text "Invoiced" into SalesStatus enum value "Invoiced", you call str2enum(SalesStatus, "Invoiced"). Is it now clear?

  • Ram Kumar Profile Picture
    454 on at

    Hi André,

    This is my Spreadsheet the last field is an Enum in my table i have to  read that data from the spreadsheet and i have to store that in a variable. All the other fields in my table are String fields. 

    3730.Excel1.png

    _accountstruct = cells.item(row, 2).value().bStr();
    _expcat = cells.item(row, 3).value().bStr();

    _rescat = str2enum(cells.item(row,4).value().bStr());

    Here i succesfully Readed the data for the String fields and i stored in a string variable . But i can't able to read the Res_Cat field from the spreadsheet and store in a enum variable . 

    I need syntax for the code to read the data from the spreadsheet and to store in an enum variable .

    Thanks in advance,

    Ram.

  • nmaenpaa Profile Picture
    101,162 Moderator on at

    Ram, I think I provided you the solution in my previous post above. Did you not notice it?

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 451 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 428 Super User 2025 Season 2

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans