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

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;
        }
 
    }
 
  • Verified answer
    Bharani Preetham Peraka Profile Picture
    3,624 Moderator on at
    How to pass tax registration number in custtable
    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.
  • Layan Jwei Profile Picture
    7,782 Super User 2025 Season 1 on at
    How to pass tax registration number in custtable
    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
  • Martin Dráb Profile Picture
    233,013 Most Valuable Professional on at
    How to pass tax registration number in custtable
    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?

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,261 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 233,013 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans