Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Suggested answer

Change data type from integer to decimal

(3) ShareShare
ReportReport
Posted on by 144
Hi,
 
we use BC OnPrem and we have a special field in several tables (Sales Line + Sales Shipment Line + Sales Invoice Line) that currently has the Integer data type and is integrated into many pages, reports and codeunits. Now it is necessary that we also have to record decimal numbers here. 
 
To change the data type I would like
  1. Save the current values for this field in a separated table
  2. Change the data type of this field using ForceSync
  3. Write the separate saved values back into the tables.
Is it correct that with this procedure (via ForceSync) only the contents of this one field are deleted in the tables? And can I therefore safely do it as described above?
Or is there another danger lurking here? Since I've usually only worked with Synchronize so far, I'm a little unsure what effect this might have when using ForceSync.
 
kind regards
Ralf
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 75,883 Super User 2024 Season 2 on at
    Change data type from integer to decimal
    Hi, hope the following can give you some hints.
    In-depth testing for Force Sync mode in Production Environment (Renaming tables, Renaming fields, Changing field type…)
     
     
    Thanks.
    ZHU
  • Suggested answer
    Ram Pranav Profile Picture
    Ram Pranav 50 on at
    Change data type from integer to decimal
    Ralf,
     
    The best practice is to
    1. Obsolete the Integer field.
    2. Create a new Decimal field.
    3. Replace all the references of the old field with the new field. (You can do this in VsCode by Right Click -> Go to References)
    4. Create an Upgrade Codeunit.
    5. In the upgrade CU, use the DataTransfer datatype to transfer the value from Integer field to Decimal field.
    6. Test your functionalities, check if the values are transferred properly to the new field.
    7. Once tested thoroughly, remove the old integer field by force syncing the extension.
  • Suggested answer
    Mohamed Amine Mahmoudi Profile Picture
    Mohamed Amine Mahmoudi 10,770 Super User 2024 Season 2 on at
    Change data type from integer to decimal
    if your are not sure you can test in sandbox environment.
    BR
    Mohamed Amine MAHMOUDI
  • neckit Profile Picture
    neckit 144 on at
    Change data type from integer to decimal
    That is not correct. Synchronize is not accepted here and an initial test with ForceSync showed that the field values are then deleted. But I'm still unsure what further consequences this could have and whether my approach is advisable!
  • Suggested answer
    Mohamed Amine Mahmoudi Profile Picture
    Mohamed Amine Mahmoudi 10,770 Super User 2024 Season 2 on at
    Change data type from integer to decimal
    Hi @neckit,
    I don't think there is any deletion in this case since the change from integer to decimal type
    also you can use Synchroise mode
    Best regards,
    Mohamed Amine MAHMOUDI

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,468 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans