Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

One field not updating with .Net Business Connector

Posted on by Microsoft Employee

Hi,

I have a simple integration for AP Invoice Journals for AX 4.0 with .Net Business Connector which is working great for the most part.

However, for some reason the "Name" field is not updating along with all the others.

The filed defaults from the Journal Name >> Description but it won't let me put in a specific value.

Any ideas? Example below and thanks in advance.

AxaptaRecord ledgerJournalTable = ax.CreateAxaptaRecord("LedgerJournalTable");

               AxaptaRecord ledgerJournalTrans = ax.CreateAxaptaRecord("LedgerJournalTrans");

               AxaptaRecord ledgerJournalName;

               AxaptaObject ledgerJournalCheckPost = ax.CreateAxaptaObject("LedgerJournalCheckPost");

               AxaptaObject numberSeq = ax.CreateAxaptaObject("NumberSeq");

               //Begin transaction

               ax.TTSBegin();

               ledgerJournalTable.set_Field("JournalName", "Comm");

               ledgerJournalTable.set_Field("Name", "Test Name Here");  // description for this journal

               ledgerJournalTable.Call("initFromLedgerJournalName");

               ledgerJournalTable.Call("insert");

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: One field not updating with .Net Business Connector

    Got it, that worked. Thanks for the help!

    Cheers,

    Adam

  • Verified answer
    Daniel Weichsel Profile Picture
    Daniel Weichsel 1,657 on at
    RE: One field not updating with .Net Business Connector

    Hi Adam,

    Your AxaptaRecord object will already have its RecId and JournalNum fields set as soon as the Insert call has completed.  You can just set the name field and call Update without having to re-select the record.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: One field not updating with .Net Business Connector

    Hey Daniel,

    I agree with your first option and already had that option ready to test.

    One question, though... After calling the insert, what is the easiest way to retrieve the JournalNum or RecID of the newly inserted record so that I know what record to update?

    Thanks again,

    Adam

  • Suggested answer
    Daniel Weichsel Profile Picture
    Daniel Weichsel 1,657 on at
    RE: One field not updating with .Net Business Connector

    Turns out that the insert() method on LedgerJournalTable is overridden and will call initFromJournalName again in cases where it needs to set the journal ID.

        if (!this.JournalNum)
        {
            this.JournalNum = JournalTableData::newTable(this).nextJournalId();

            if (!this.JournalNum)
                throw error("@SYS27388");

            this.initFromLedgerJournalName();
        }

    So I see two options here:

    1.  Insert the record first and then update it with the description.

    2.  Set the JournalNum field using logic similar to that in the insert method, to prevent the initFromLedgerJournalName method from being called again.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: One field not updating with .Net Business Connector

    Hi Daniel,

    Thanks for catching that and it would seem that it should have fixed it but it does not.

    I swapped the order of the two lines but got the same result.

    Any other ideas?

    Thanks again,

    Adam

  • Suggested answer
    Shashi s Profile Picture
    Shashi s 1,203 on at
    RE: One field not updating with .Net Business Connector

    As Daniel mentioned do that.

    The class that gets called from the method "initFromLedgerJournalName" is LedgerJournalTableData.

    Check the method initFromJournalName in this class, the Name fields gets set over here too.

  • Daniel Weichsel Profile Picture
    Daniel Weichsel 1,657 on at
    RE: One field not updating with .Net Business Connector

    Hi Adam,

    Try swapping the order of setting the Name field and calling initFromLedgerJournalName.  The initFrom... method is overwriting the description with a default description defined on the LedgerJournalName record.

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,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans