Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Answered

How to set space in .txt file for blank record

(1) ShareShare
ReportReport
Posted on by 171
Hi Team,
 
Using below link i have generated the .txt file.
 
If there is no data in file 0 should come.
 
Please let me know how zero will come instead of blank.
  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 230,962 Most Valuable Professional on at
    How to set space in .txt file for blank record in D365FO
    For example:
    private str zeroIfEmpty(str _input)
    {
        return _input ? _input : '0';
    }
    
    ...
    io.write(... this.zeroIfEmpty(custTable.CustGroup)));
  • Suggested answer
    Mohit Rampal Profile Picture
    Mohit Rampal 12,554 Super User 2024 Season 1 on at
    How to set space in .txt file for blank record in D365FO
    Hi, You can set value zero if field value is blank but you need to add it in String as all your fields are string fields.
     
    while select custTable
    {
    
      if (!custTable.custGroup)
      {
          custTable.custGroup = "0";
      }
    }
     
  • CU21091228-0 Profile Picture
    CU21091228-0 171 on at
    How to set space in .txt file for blank record in D365FO
    Could you please provide me the sample code?
  • Martin Dráb Profile Picture
    Martin Dráb 230,962 Most Valuable Professional on at
    How to set space in .txt file for blank record in D365FO
    You provide values and call write() method at line 24.
  • CU21091228-0 Profile Picture
    CU21091228-0 171 on at
    How to set space in .txt file for blank record in D365FO
    Hi Martin.
    Please let me know at which place should i write '0'
  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 230,962 Most Valuable Professional on at
    How to set space in .txt file for blank record in D365FO
    It's sounds simple - replace empty strings with '0' before calling TextStreamIo.write().

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,162 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,962 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans