Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

String field need to change in Real Field

Posted on by 205

Hey Experts,

Actually , In starting we developed a table which have one string field for putting values example "100 & 200". But some users entered value like" space 100 & space 200". so that's create problem for getting report through Power BI.

So my question is, Their any possibility to change string field to real filed on user interface form level. So user can only enter real value.

*This post is locked for comments

  • Suggested answer
    startax Profile Picture
    startax 1,845 on at
    RE: String field need to change in Real Field

    Hi DEEPAKNONU,

    If you are changing field type str to real or int then you have to change in Form control, Reports also. Also in code if you are used.

    Better create new field and update data in table.

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: String field need to change in Real Field

    You can't do calculations based on string fields, so you should definetely use a numeric data type.

  • Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: String field need to change in Real Field

    Then add validation to check that only numbers are entered, you can use str2NumOk() function to check that. However, I would recommend to change field type instead.

  • DEEPAKNONU Profile Picture
    DEEPAKNONU 205 on at
    RE: String field need to change in Real Field

    thanks, for you response Nikolaos, I need that field act like a real value this field used for enter quantity value only  because sometimes  user give space in before enter the the quantity it create problem.

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: String field need to change in Real Field

    But the correct solution really depends on your full requirement which we don't know. If only numbers should be allowed, use real or int type. If you need to allow alphanumeric characters, use string.

    You can also link your string field to another table where all allowed values can be defined. Examples of such pattern in standard system include customer group, item group, zip code etc.

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: String field need to change in Real Field

    You can't change the primitive data type of an existing field. You need to create a new field with a new type. Then change your application code to use the new field. You need also to create a runnable class that will migrate data from your old field to the new field.

    Now you can deploy those changes to test and prod, and run the migration class. In the next  deployment you can remove the old field.

    Do not simply delete your old field and add a new one with the same name, because this would fail in database sync, preventing you from deploying it to test / prod.

  • DEEPAKNONU Profile Picture
    DEEPAKNONU 205 on at
    RE: String field need to change in Real Field

    Thanks ievgen, I appreciate your quick response, Can you please explain little bit more how can I change the field on table because on field properties type is not editable. And  in this field used EDT which is also string.

  • Suggested answer
    Khurshid Wali Profile Picture
    Khurshid Wali 922 on at
    RE: String field need to change in Real Field

    Hello Deepaknonu,

    The best way is to change the table field from string to real or int. Ax will handle all the validations for you. If you can't make changes to the table then override the validate method of that field in the form and only allow proper real numbers.

    if the problem is only left-right 'space' override the modified method and use strLtrim and strRtrim to get rid of right and left space.

    regards,

    Khurshid wali

  • Suggested answer
    Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: String field need to change in Real Field

    If you want them to enter "100" you need to change field type to real or int on the table. If you want to let them enter "100 & 200" then you need to implement validation on the field and check that string formatted as you like.  

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans