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 :
Microsoft Dynamics AX (Archived)

CustAgingReport Insert_recordset with method and join

(0) ShareShare
ReportReport
Posted on by 1,214

Hi. I'm adding extra information on CustAgingReport and it's using insert_recordset to copy data into temporary table. I added fields from CustTable and it's working fine.

The problem is getting a value from method. I tried assigning the value to variable first but obviously it will return empty value. 

Please help correct my approach. Thank You. 

CustTable tmpCustTable;

Phone contactNo;

contactNo = tmpCustTable.phone();

INSERT_RECORDSET custAgingReportTmp
(AccountNum, Name, CustAccount, Txt, Currency, CustGroup, BillingClassification, Balance, ContactNo, SortOrder, SalesGroup, CreditMax, CreditMaxCust, SegmentId, PaymTermId) 
SELECT
AccountNum, Name, AccountNum, Txt, CurrencyCode, GroupId, BillingClassification, balance, contactNo 
FROM tmpAccountSum
JOIN SortOrder
FROM custVendTransAging
WHERE tmpAccountSum.AccountNum == custVendTransAging.AccountNum
JOIN SalesGroup, CreditMax, CreditMaxCust, SegmentId, PaymTermId
FROM tmpCustTable
WHERE tmpCustTable.AccountNum == tmpAccountSum.AccountNum;

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Brandon Wiese Profile Picture
    17,788 on at

    You cannot use a method in an INSERT_RECORDSET.  The kernel attempts to construct a single set based SQL statement from the INSERT_RECORDSET, and SQL Server will have no idea what AX methods are, for starters.  You could break the INSERT_RECORDSET into a standard WHILE SELECT { } statement, but there will be a heavy performance penalty for a record loop vs a set based SQL statement.

    A better approach would be to use a display method on your report that takes the AccountNum and returns the .phone() method from that CustTable record.

  • HAIRUL HAZRI Profile Picture
    1,214 on at

    Hi Brandon.

    Thank you the clarification.

    But, this CustAgingReport is using RDP. From what I understand, display methods can only be used in query based report. Right?

    Can you suggest any other suitable approach?

    Thank You.

  • HAIRUL HAZRI Profile Picture
    1,214 on at

    CustAgingReport is related to many classes and using a lot of temptable. All insert method for those temptables are using insert_recordset just like this. So I don't think it will work.

  • Verified answer
    HAIRUL HAZRI Profile Picture
    1,214 on at

    My solution is to manually join the related tables on CustTable.phone() method into the insert_recordset query and get the field directly.

    INSERT_RECORDSET custAgingReportTmp
    (AccountNum, Name, CustAccount, Txt, Currency, CustGroup, BillingClassification, Balance, SortOrder, SalesGroup, CreditMax, CreditMaxCust, SegmentId, PaymTermId, ContactNo
    SELECT
    AccountNum, Name, AccountNum, Txt, CurrencyCode, GroupId, BillingClassification, balance
    FROM tmpAccountSum
    JOIN SortOrder
    FROM custVendTransAging
    WHERE tmpAccountSum.AccountNum == custVendTransAging.AccountNum
    JOIN SalesGroup, CreditMax, CreditMaxCust, SegmentId, PaymTermId
    FROM tmpCustTable
    WHERE tmpCustTable.AccountNum == tmpAccountSum.AccountNum

    join dirPartyTable

    where tmpCustTable.Party == dirPartyTable.RecId

    join Locator

    from logisticsElectronicAddress

    where logisticsElectronicAddress.RecId == dirPartyTable.PrimaryContactPhone;

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Priya_K Profile Picture

Priya_K 4

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#3
Sukrut Parab Profile Picture

Sukrut Parab 2 Moderator

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans