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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

How to assign value to formdatasource field when modifying other formdatasource field in d365 using eventhandler

(0) ShareShare
ReportReport
Posted on by 960

Hi all,

I hav a Form name MyForm with Datasources DSA, DSB. i will type a value in DSA-field1. now i need to assign this value in DSB- field2. i am trying in FormDataFieldEventhandler.

how to fetch other datasource record (DSB) here while modifying DSA-fieldlevel.

Any suggestions plss.

Thanks in advance,

  • Suggested answer
    Sergei Minozhenko Profile Picture
    23,099 on at

    Hi Test Bot,

    If MyForm is your own form, you don't need to use event handlers. Use methods on form instead.

    I would recommend using 'write' method on DSA data source and after 'super' statement update value in DSB table with update_recordset statement and refreshing DSB data source.

  • Suggested answer
    nmaenpaa Profile Picture
    101,174 Moderator on at

    Why do you want to duplicate this value in the other table / data source? Normally you should try to avoid that, instead store the data in one place and access it via table relations from other places.

    Anyway, if you do, and if it's your own form, you don't need to use event handlers (as Sergey mentioned).

    And you could also consider putting the code in insert and update (and delete?) methods of the table, instead of the form. This way the logic would work from any process that writes into that table.

  • TestBot Profile Picture
    960 on at

    Hi Nikolaos and Sergei,

    thanks for your suggestions .

    Its a standard form. i need at form level modifying the data.

  • Suggested answer
    Sergei Minozhenko Profile Picture
    23,099 on at

    Hi Test Bot,

    In this case, I still suggest using "OnWritten' event and update_recordset with DSB data source refresh option. In this case, if user will change values several times, you don't need to do unecesary updates to DSB before user decide to fix changes.

  • Verified answer
    MATTGUO Profile Picture
    22,353 Moderator on at

    Hi Test Bot,

    You could use the below code, SalesTable>DSA ,SalesLine>DSB:  

    [FormDataFieldEventHandler(formDataFieldStr(SalesTable, SalesTable, AccountingDistributionTemplate), FormDataFieldEventType::Modified)]

       public static void AccountingDistributionTemplate_OnModified(FormDataObject sender, FormDataFieldEventArgs e)

       {

           FormRun formRun = sender.datasource().formRun();

           FormDataSource salesline_ds = formRun.dataSource("SalesLine");

           salesline_ds.yourfield=......

       }

  • TestBot Profile Picture
    960 on at

    Hi Mattguo,

    Thanks . it worked.

  • TestBot Profile Picture
    960 on at

    Hi Sergio,

    i will try your suggestion as well. thanks for the quick reply.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 239 Super User 2026 Season 2

#2
Aayush Tiwari Profile Picture

Aayush Tiwari 221

#3
Subra Profile Picture

Subra 166 Super User 2026 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans