Skip to main content

Notifications

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.

  • Bharani Preetham Peraka Profile Picture
    Bharani Preetham Pe... 3,587 Super User 2024 Season 1 on at
    RE: Change default values of standard fields in a standard form

    Please verify the answers which ever helped you.

  • Suggested answer
    RE: Change default values of standard fields in a standard form

    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!

  • Suggested answer
    Mohit Rampal Profile Picture
    Mohit Rampal 12,552 Super User 2024 Season 1 on at
    RE: Change default values of standard fields in a standard form

    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

  • RE: Change default values of standard fields in a standard form

    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...

  • Verified answer
    Bharani Preetham Peraka Profile Picture
    Bharani Preetham Pe... 3,587 Super User 2024 Season 1 on at
    RE: Change default values of standard fields in a standard form

    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.

  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 230,836 Most Valuable Professional on at
    RE: Change default values of standard fields in a standard form

    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.

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,965 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,836 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans