Skip to main content

Notifications

Announcements

No record found.

Business Central forum
Suggested answer

How do I create and link an editable field to two tables using Events

Posted on by 30
Hello,
I've created a table and a page for my field and I've extended the Customer table and Sales Header.
Basically, I want to create a new field in the customer table, card, and list. This field needs to appear also in the Sales Invoice under the customer's name.
The idea here is that if I change the field value in the Sales Invoice page, the value is automatically changed in Customer.
In order to achieve that, I need to use Events.
This is where it gets tough for me, the field needs to be editable so it can't be of class FlowField. However, the value cannot be fetched
from Customer if the field isn't Flowfield (through CalcForm).

I'm completely lost as to how to link the field and make it editable.
(Note: I'm using AL to write my code.)
How do I solve this issue?
Categories:
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 63,857 Super User on at
    RE: How do I create and link an editable field to two tables using Events

    Hi, a simple example, hope this will help. (This is not the only way)

    Add field:

    pastedimage1636678189621v1.png

    Add logic:

    pastedimage1636678208779v2.png

    Thanks.

    ZHU

  • Something Profile Picture
    Something 30 on at
    RE: How do I create and link an editable field to two tables using Events

    Thank you for your help. My question is, do I use that example to get the user's input because otherwise, the value from my custom field list isn't showing on the customer card. It just remains empty

  • Suggested answer
    JAngle Profile Picture
    JAngle 33,135 on at
    RE: How do I create and link an editable field to two tables using Events

    Example here with code snippets: docs.microsoft.com/.../devenv-events-example

    Event subscribers are triggered by the event itself. For example OnAfterValidate of a field. Once the standard table OnValidate code has run an event subscribers would be called

  • Something Profile Picture
    Something 30 on at
    RE: How do I create and link an editable field to two tables using Events

    Hello. I appreciate your reply.

    Can you please elaborate on how would that look like in code? I'm new to development, and I'd appreciate an example. (For example, if I create an event subscriber where do I call it from?)

    Thank you!

  • Suggested answer
    Akshay_Panchal Profile Picture
    Akshay_Panchal 400 on at
    RE: How do I create and link an editable field to two tables using Events

    Hii,

    You can write your code under the OnafterValidateEvent of your customized field.

    Thanks.

    Verify, If this answer is helpful to you.

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,696 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,490 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans