web
You’re offline. This is a read only version of the page.
close
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 initialize temp table values in form inti method?

(0) ShareShare
ReportReport
Posted on by 148

below is my code but I'm not getting values, please help.

public void init()
{

super();

select * from taxRegistration
outer join taxRegistrationTypeApplicabilityRule
where taxRegistration.TaxRegistrationTypeApplicabilityRule == taxRegistrationTypeApplicabilityRule.RecId
outer join taxRegistrationType
where taxRegistrationTypeApplicabilityRule.TaxRegistrationType == taxRegistrationType.RecId
// && taxRegistrationType.RecId == _regTypeRecId
outer join dirPartyLocation
where taxRegistration.DirPartyLocation == dirPartyLocation.RecId
&& dirPartyLocation.IsPrimary == NoYes::Yes
outer join dirPartyTable
where dirPartyLocation.Party == dirPartyTable.RecId
outer join custTable
where custTable.Party == dirPartyTable.RecId;
// && custTable.AccountNum == custAccount;
ttsbegin;


taxRegistrationTmp.AccountNum = custTable.AccountNum;
taxRegistrationTmp.Name = dirPartyTable.Name;
taxRegistrationTmp.ValidTo = taxRegistration.ValidTo;
taxRegistrationTmp.RegistrationNumber = taxRegistration.RegistrationNumber;
taxRegistrationTmp.insert();


ttscommit;

}

Thanks in advance.

I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    237,896 Most Valuable Professional on at

    Did you test that your query fetches anything? Is TaxRegistrationTmp a form data source? Are there any joins or ranges?

    By the way, please use Insert > Code (in the rich formatting view) to paste source code. Among other things, it preserves indentation, which makes code easier to read. For example:

    public void init()
    {
    	super();
    
    	select firstonly RegistrationNumber, ValidTo from taxRegistration
    		outer join taxRegistrationTypeApplicabilityRule
    			where taxRegistrationTypeApplicabilityRule.RecId == taxRegistration.TaxRegistrationTypeApplicabilityRule
    			outer join taxRegistrationType
    				where taxRegistrationType.RecId == taxRegistrationTypeApplicabilityRule.TaxRegistrationType
    		outer join dirPartyLocation
    			where dirPartyLocation.RecId == taxRegistration.DirPartyLocation
    			   && dirPartyLocation.IsPrimary == NoYes::Yes
    			outer join Name from dirPartyTable
    				where dirPartyTable.RecId == dirPartyLocation.Party
    		outer join AccountNum from custTable
    			where dirPartyTable.RecId == custTable.Party
    
    	taxRegistrationTmp.AccountNum = custTable.AccountNum;
    	taxRegistrationTmp.Name = dirPartyTable.Name;
    	taxRegistrationTmp.ValidTo = taxRegistration.ValidTo;
    	taxRegistrationTmp.RegistrationNumber = taxRegistration.RegistrationNumber;
    	taxRegistrationTmp.insert();
    }

    I also added field lists to make your query more efficient. And I've noticed that you're fetching taxRegistrationTypeApplicabilityRule and taxRegistrationType, but you never use them.

  • Prasanth Profile Picture
    148 on at

    Which object it is about? You told us that it has init() method, but not whether it's a class (and which one), a form or what.

    Ans :  It's a form. I'm writing this code in form init method.

    I also added field lists to make your query more efficient. And I've noticed that you're fetching taxRegistrationTypeApplicabilityRule and taxRegistrationType, but you never use the

    Ans :  I have to use taxRegistrationTypeApplicabilityRule and taxRegistrationType for further useage. I have to get registration number by type. so that's why I'm taking those two.

    while debugging I'm getting tax registration number only, but accountnum is not came.

    please help, how to overcame this issue.

  • Verified answer
    Martin Dráb Profile Picture
    237,896 Most Valuable Professional on at

    If you get a tax registration number but not AccountNum, it means that you query didn't find any CustTable record. Your problems lies either in your query or your data.

    I understand that you may need taxRegistrationTypeApplicabilityRule and taxRegistrationType, for something else but it's irrelevant to the problem that we're dealing with. Let's not make it more complex than necessary.

  • Prasanth Profile Picture
    148 on at

    Actually I need AccountNum from CustTable and Name from DirPartyTable and RegistrationNumber from TaxRegistration based on type.

    I need to show these fields in my form.

    but how to do this requirement. I'm fresher with just 3 months of experience . Please help me .

  • Verified answer
    Martin Dráb Profile Picture
    237,896 Most Valuable Professional on at

    You used outer joins, which say that you need taxRegistration, but dirPartyTable.Name and CustTable.AccountNum are optional. If you always must have them, then using outer joins looks wrong.

    If no data exists for your conditions, you need to either change the conditions or create the right data.

    If you believe that you have the data, then debug your query. First of all, take taxRegistration.DirPartyLocation and check if there is DirPartyLocation with such RecId and IsPrimary = Yes.

  • Prasanth Profile Picture
    148 on at

    but how to get accountNum and name, which joins can I use?

    it makes totally confusing me. please guide how to get accountnum and name. I will try to get registration number.

  • Verified answer
    Martin Dráb Profile Picture
    237,896 Most Valuable Professional on at

    I think you start from the beginning. Which TaxRegistration record are you trying to find? You have not a single condition for it, therefore you'll get the record that the database server finds first. This doesn't look useful, therefore it's most likely a bug. And all the other data won't make sense either if we start with a wrong TaxRegistration.

    Or was your intention to find all TaxRegistration records?

  • Prasanth Profile Picture
    148 on at

    yes, find all tax registration records.

    if customer having taxregistration, it will show otherwise it will blank but customer account and name will display.

  • Prasanth Profile Picture
    148 on at

    pastedimage1644391049563v1.png

    for your reference.

  • Prasanth Profile Picture
    148 on at

    I'm changing my code to below format

    public void init()

       {  

           super();

           ttsbegin;

           insert_recordset taxRegistrationTmp(ValidTo, Name,AccountNum )

               select ValidTo from taxRegistration

                join taxRegistrationTypeApplicabilityRule

               where taxRegistration.TaxRegistrationTypeApplicabilityRule == taxRegistrationTypeApplicabilityRule.RecId

                    join taxRegistrationType

                   where taxRegistrationTypeApplicabilityRule.TaxRegistrationType == taxRegistrationType.RecId

                      // && taxRegistrationType.RecId == _regTypeRecId

            join dirPartyLocation

                           where taxRegistration.DirPartyLocation == dirPartyLocation.RecId

                              && dirPartyLocation.IsPrimary == NoYes::Yes

                                join Name from dirPartyTable

                               where dirPartyLocation.Party == dirPartyTable.RecId

                                    join AccountNum from custTable

                                       where custTable.Party == dirPartyTable.RecId;

                                     //  && custTable.AccountNum == custAccount;

           if(taxRegistrationType.ApntTaxRegistrationType == ApntTaxRegistrationType::TRN)

           {

               taxRegistrationTmp.RegistrationNumberTRN = taxRegistration.RegistrationNumber;

               taxRegistrationTmp.insert();

           }

           if(taxRegistrationType.ApntTaxRegistrationType == ApntTaxRegistrationType::TRL)

           {

               taxRegistrationTmp.RegistrationNumberTRL = taxRegistration.RegistrationNumber;

               taxRegistrationTmp.insert();

           }

           ttscommit;

       }

    But I'm not getting values.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 544 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 450 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 250 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans