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 pass tax registration number in custtable

(0) ShareShare
ReportReport
Posted on by 123
Hi there! can you please help me with this code.
here i am passing taxregistrationnumber from taxregistration table to the custtable, but the issue is that it is being passed but selecting one customer for every change.
that it has to be changed for the every customer which we have selected.
 
 
 
/// </summary>
    /// <param name=/sender/></param>
    /// <param name=/e/></param>
    [FormDataSourceEventHandler(formDataSourceStr(LogisticsPostalAddress, TaxRegistration), FormDataSourceEventType::Written)]
    public static void TaxRegistration_OnWritten(FormDataSource sender, FormDataSourceEventArgs e)
    {
        TaxRegistration         taxRegistration;
        TaxRegistrationType     taxRegistrationType;
        CustTable custTable;
        DirPartyTable dirpartytable;
        DirPartyLocation dirpartylocation;
        FormRun formRun = sender.formRun();
        FormDataSource taxRegistration_ds = formRun.dataSource(formDataSourceStr(LogisticsPostalAddress, TaxRegistration));
        TaxRegistration    _taxregistration = taxregistration_ds.cursor();
       //TaxRegistration    _taxregistration = sender.dataSource(/taxRegistration_ds/).cursor();
        TaxRegistration  tax;
       // str reg=_taxregistration.orig().RegistrationNumber;
        //_taxregistration tax=_taxregistration.orig();
 
        SELECT CustTable JOIN DirPartyTable
            WHERE CustTable.Party == DirPartyTable.RecId
            JOIN DirPartyLocation
            WHERE DirPartyLocation.Party == DirPartyTable.RecId
            JOIN tax
            WHERE tax.DirPartyLocation == DirPartyLocation.RecId
            && tax.RegistrationNumber==_taxregistration.RegistrationNumber;
            //&& tax.RegistrationNumber==reg;
 
 
      //CustTable custtable;
        select forUpdate custTable;
        if(CustTable)
        {
            ttsbegin;
            //custTable.XTSVATNum = taxregistration::find(custTable.party).RegistrationNumber;
            custTable.XTSVATNum = taxregistration.RegistrationNumber;
            custTable.update();
 
           // custTable.XTSVATNum = taxregistration.RegistrationNumber;
           ttscommit;
        }
 
    }
 
I have the same question (0)
  • Martin Dráb Profile Picture
    238,780 Most Valuable Professional on at
    There is a huge bug in your code. You select a customer based on tax registration, but then you throw this information away and you always select the first customer in the table (by select forUpdate custTable;)
     
    When you say "every customer which we have selected", how will you select the customers?
  • Layan Jwei Profile Picture
    8,165 Super User 2026 Season 1 on at
    Hi M_R,

    It's not clear what do you mean by you need it to be changed "for every customer which you have selected"
    can you please explain exactly what are you trying to do?

    Thanks,
    Layan Jweihan
  • Verified answer
    Bharani Preetham Peraka Profile Picture
    3,634 Moderator on at
    If you are saying selecting 'one customer for every change' means query is selecting the first customer only, if my understanding is correct, then yes, the select statement which you are selecting will select only first customer because you are overriding the buffer by 'select forupdate custtable' statement.
     
    To make your code readable and work, firstly, remove this update statement. Secondly, you should use the buffers defined not actual names when using in code. And you need to write custTable.selectforupdate(true); and then you need to update it.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 514 Super User 2026 Season 1

#2
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 390

#3
Adis Profile Picture

Adis 266 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans