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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Compare .csv file to active table with unsaved data

(0) ShareShare
ReportReport
Posted on by 3,850

Hello

I'm open a Journal form and writing an records to that journal. I haven't saved it or doing anything unless just create some records.

Then there is a button on the Journal form who I have created named "Import file for comparison" - and then a RunBase dialog appear who give me opportunity to import a file and do some comparison work.

Here is a code snippet who display information in the file into infolog box.

But I need to compare the records who is open in my form, to the information in the CSV file.

If (!file || file.status() != IO_Status::Ok)
{
throw error("File cannot be opened");
}

line = file.read();

while (file.status() == IO_Status::Ok)
{
info(con2Str(line, '-'));
line = file.read();
}

The While statement needs to be modified. The code isn't exactly what I'm doing but we can assume that "info" line in the while statement should be replaced with statement who compare the line in the file with the active records in the form and the output should be something that doen't matter.

I just need to know what trigger the active table in the form so I can compare with the imported file. 

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Community Member Profile Picture
    on at

    You can find the active records using Form datasource Table name

    As you are using Journal form (LedgerJournalTable)

    in this form if you go to the DataSource node

    you will find a datasource named LedgerJournalTable

    so in your code you can use LedgerJournalTable as active record

    Please verify and update if above information helps you.

  • Sandri Profile Picture
    3,850 on at

    Thanks Nitesh

    Can you give me sample of statement?

    Like:

    FormDatasourse       LedgerJournarTable;

  • Suggested answer
    Community Member Profile Picture
    on at

    sample statement can be like this

    If (!file || file.status() != IO_Status::Ok)

    {

    throw error("File cannot be opened");

    }

    line = file.read();

    while (file.status() == IO_Status::Ok)

    {

    if(LedgerJournalTable.JournalNum == conpeek(line,1) && LedgerJournalTable.Name == conpeek(line,2))

    {

          //Do something for this line

    }

    line = file.read();

    }

  • Martin Dráb Profile Picture
    237,795 Most Valuable Professional on at

    Look at Tutorial_CompareContextProvider class - it shows how you can use the framework used for comparing code to compare other things.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans