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 :
Finance | Project Operations, Human Resources, ...
Answered

Change default values of standard fields in a standard form

(0) ShareShare
ReportReport
Posted on by 45

Hello everyone!
I need some help in understanding how to change the default value of a field in a standard form through extension. I have searched both in this forum and on google, finding some different solutions, but I noone of them have worked for me (or, maybe, I have applied them in the wrong way). I am working on dynamics 365 version 10.0.29

Here is my case in detail:
- When you have to post a new vendor invoice, you go to Accunts payable -> Invoices -> Invoice Journal. Here, you create a new journal, then you open it clicking on its voucher or on the "Lines" button above. In this form there is a tab called "Invoice" and inside it a group called "Approve". In this group there is a flag called "Approved" that's true by default, and a lookup called "Approved by" with the name of the approver. All these things are standard Microsoft.

7536.pastedimage1681979885590v1.png
- What I need to achive is to change the default values of the field so that the flag is false by default and the user will eventually change it if needed, and the lookup should be empty.
- This fields should be on the "LedgerJournalTrans" table, as far as I know.
- As I am extending the standard, I have a limted range of choices to achive it: I can't change the default value of the fields from the form extension in Visual Studio, and I can't use the methods but only the events provided.
- I tried retrieving the controls of the form and changing their values; I tried retrieving the datasource in various points of execution (form init, datasource init, etc) and change the values of the fields directly on it... Sometimes I received a null pointer exception, sometimes I had no errors but the fields were unchanged.
- Searching in the code, I suspect that there is some standard code that initialize this fields automatically based on the type of journal you are using, but I am not sure. In particular, I suspect that the ckass LedgerJournalEngine is involved in a way I still don't understand, but maybe I am wrong.

8883.pastedimage1681979958143v2.png

I thught that would be an easy task, but seems I was wrong. I hope anyone will be able to help me.

I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    237,878 Most Valuable Professional on at

    The first step is finding which field the control is bound to, if any. Just assuming that it's a field on LedgerJournalTrans isn't good enough. You should be able to find the information in Fom information form. Then you can use references to see where the field is used.

    If you find that the control isn't bound to any field, copy the name of the control, open the form definition and search for code using the control.

  • Verified answer
    Bharani Preetham Peraka Profile Picture
    3,634 Moderator on at

    Adding to Martin, once you found exact field name, just go to table, find ref and see wherever it is used and try checking how this default is made. That will give you exact place. Also, you can try doing a COC for init() or initValue() or post eventhandler for the same.

  • Andrea Casagrande Profile Picture
    45 on at

    Hi Martin,

    you are right. In fact, it was one of the things I did, but I have not mentioned everything in my first post or it would have been to much long ;-)

    Anyway, the flag control refers to table "LedgerJournalTrans" and to its field "approved" as you can see:

    pastedimage1681984778104v1.png

    Trying to follow the flag field, at this point the problem I had was that it has 191 references, quite a lot:

    pastedimage1681984864026v2.png

    It was here that I found of the LedgerJournalEngine class I mentioned in the first post, in particular there is an extension class for it called LedgerJournalEngine_VendInvoice that as has a method inside called initValue that initialize my two fields:

    pastedimage1681984908267v3.png

    Do you think I should try to use COC on that method and see if it works? I just thought of it now while writing, I will try and let you know...

  • Suggested answer
    Mohit Rampal Profile Picture
    12,565 Moderator on at

    Hi Andrea, Approver and Approved field is mapped in couple of forms & classes as below. How about extending insert method of LedgerJournalTrans table and check if LedgerJournalType is VendInvoiceRegister (For LedgerJournalTable9 menu item) then empty these two fields before calling next statement.

    pastedimage1681985343279v1.png

  • Suggested answer
    Andrea Casagrande Profile Picture
    45 on at

    Hi everyone!

    I have done what I say here, using COC on the method initValue of the class LedgerJournalEngine_VendInvoice: first it calls next on it, then I change the values to what I need. It works!

    Thanks everyone for the help!

  • Bharani Preetham Peraka Profile Picture
    3,634 Moderator on at

    Please verify the answers which ever helped you.

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 646 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 529 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 285 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans