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

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

One field not updating with .Net Business Connector

(0) ShareShare
ReportReport
Posted on by

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

I have the same question (0)
  • Daniel Weichsel Profile Picture
    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.

  • Suggested answer
    Shashi s Profile Picture
    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.

  • Community Member Profile Picture
    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
    Daniel Weichsel Profile Picture
    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
    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

  • Verified answer
    Daniel Weichsel Profile Picture
    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
    on at
    RE: One field not updating with .Net Business Connector

    Got it, that worked. Thanks for the help!

    Cheers,

    Adam

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…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Tocauer Profile Picture

Martin Tocauer 4

#2
Alexey Lekanov Profile Picture

Alexey Lekanov 2

#2
NNaumenko Profile Picture

NNaumenko 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans