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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Convert SalesStatus from enum to str?

(0) ShareShare
ReportReport
Posted on by

Hello there,

I am writing a Document service for the SalesTable and i want to convert the Sales Status which is an enum to  a string and therfore i have done the following:

[DataMemberAttribute('SalesStatus')]
public str parmSalesStatus(str _SalesStatus = SalesStatus)
{
SalesStatus = _SalesStatus;
return SalesStatus;
}

mapsales
this.parmSalesStatus(enum2str(_sales.SalesStatus));

Will this in anyway effect anything? I just want to make sure nothing wrong happens and i get the values.

*This post is locked for comments

I have the same question (0)
  • Mea_ Profile Picture
    60,286 on at

    What is wrong with enum, why are you doing this ?

  • Community Member Profile Picture
    on at

    Just want it as a string? Any problem with doing this?

  • Mea_ Profile Picture
    60,286 on at

    Because if you have method that returns enum in AX like this :

    [DataMemberAttribute]
    
    public SalesType SalesType(SalesType _salesType = salesType)
    
    {
    
      salesType = _salesType;
    
      return salesType;
    
    }
    

    in c sharp you will use it next way :

    SalesType = ServiceReference.SalesType.ItemReq

    And if you will try to pass any random text you will get compile time error.

    In case of strings you can type any random value like

    SalesType = "12345657";

    and will get runtime error.

  • Community Member Profile Picture
    on at

    Actually it worked.

    Thanks anyways.

  • Verified answer
    Mea_ Profile Picture
    60,286 on at

    I did not say that it won't work :)

    I'm saying that using enums is safer that strings, that's all.

  • Community Member Profile Picture
    on at

    Enlightening, Thanks alot mate :)

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 21

#2
dserp Profile Picture

dserp 4

#2
dekion Profile Picture

dekion 4

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans