Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

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

Sorting column in ExcelBuffer NAV2018

(0) ShareShare
ReportReport
Posted on by 5

Hi everyone,

I'm new with dynamics NAV and I'm currently working on an Excel export using ExcelBuffer. I would like to know if it's possible to sort data in ExcelBuffer based on a specific column. My problem is that I need to process data from several sources and have calculated data on which I have to sort. So I can't sort on my datasource directly.

My code is something like this :

excelbuffer.createbook(...);
if myRecord.findset then begin
repeat
    entercell(data from myRecord);
    calculate myDate which is based on data from myRecord and another data source
    entercell(myDate);
until myRecord.next = 0;
end;

//need to sort excelbuffer on myDate

excelbuffer.writesheet(...);
excelbuffer.closebook;
excelbuffer.openexcel;
excelbuffer.giveusercontrol;

We are working with NAV2018 and VS Code

Thank you

Aurore

  • Aurore999 Profile Picture
    5 on at
    RE: Sorting column in ExcelBuffer NAV2018

    Hi TechWorld

    Thank you for your answer. I didn't use SETCURRENTKEY on "myRecord" because the field (myDate) on which I want to sort the ExcelBuffer is not part of "myRecord". This is column I add to the ExcelBuffer and that is calculated when go through all records in "myRecord".

    Aurore

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: Sorting column in ExcelBuffer NAV2018

    Have you tried sorting by SETCURRENT Key?

    you can define fields on basis of which your sorting is to be done

    https://docs.microsoft.com/en-us/dynamics-nav/setcurrentkey-function--record-

    excelbuffer.createbook(...);

    MYRECORD.SETCURRENTKEY(FIELD1,FIELD2,FIELD3);
    if myRecord.findset then begin

  • Aurore999 Profile Picture
    5 on at
    RE: Sorting column in ExcelBuffer NAV2018

    Hello Marco,

    Thank you for your response. I will take a look at your links for additional support.

    Have a nice day,

    Best regards,

    Aurore

  • Suggested answer
    Marco Mels Profile Picture
    on at
    RE: Sorting column in ExcelBuffer NAV2018

    Hello,

    We currently do not have dedicated Dev support via the Dynamics 365 Business Central forums, but I wanted to provide you some additional resources to assist.  If you need assistance with debugging or coding I would recommend discussing this on one of our communities.

    www.yammer.com/.../

    dynamicsuser.net/.../developers

    I will open this up to the community in case they have something to add.

    Thanks.

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
YUN ZHU Profile Picture

YUN ZHU 628 Super User 2025 Season 1

#2
Mansi Soni Profile Picture

Mansi Soni 495

#3
Sagar Dangar, MCP Profile Picture

Sagar Dangar, MCP 395

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans