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

Announcements

News and Announcements icon
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 (1)
  • Suggested answer
    Brandon Wiese Profile Picture
    17,790 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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Sanhthosh.Kumar.K Profile Picture

Sanhthosh.Kumar.K 2

#2
Raed Salah Bzour Profile Picture

Raed Salah Bzour 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans