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

When creating new sales Return Order how to show only those invoices posted by that user? AX 2012 R2

(0) ShareShare
ReportReport
Posted on by 1,813

Hii,

Requirement: We want that the AX user who created Sales Order invoice should create the sales Return Order. Please guide how we can restrict/filter by query or development or else on sales Return Order form to show invoices created by logged in user.

Thanks,  

*This post is locked for comments

I have the same question (0)
  • Verified answer
    André Arnaud de Calavon Profile Picture
    304,268 Super User 2026 Season 1 on at

    Hi Rana,

    What would happen if there is a need for a return order and the person who created the invoice is ill, on vacation or when he left the company? This cannot be the full requirement.

    Of course, it would be possible to achieve something using a customization (x++ or security policies), but you need to think of backup plans.

  • Rana Anees Profile Picture
    1,813 on at

    Thanks André,

    You are right and we discussed with the management and they still want to go with the solution.

    Can you please guide how and where to do customization with x++ and security policy.

    Thanks and Regards,

  • Suggested answer
    István Orosz Profile Picture
    2,137 on at

    Hi,

    On query side, you can add a filter for the current user ID, shown by the str curUserId()

    function, so SalesTable can be filtered by that. It is not easy to help without more details.

    Kind Regards,

    István

  • André Arnaud de Calavon Profile Picture
    304,268 Super User 2026 Season 1 on at

    Hi Rana,

    On the forum, I can only provide some answers. I cannot take ownership to do the customization for you. If you don't have the knowledge in house, you can do some learning or hire developers to do the work for you.

  • Suggested answer
    Mahmoud Hakim Profile Picture
    17,887 on at

    just make some customization based on curuserid

  • Verified answer
    Chaitanya Golla Profile Picture
    17,225 on at

    Hi,

    According to your business requirement, you need to perform two customizations, first one is restricting user while creating the return order and another one is to filter the data on return order list page based on current user.

    1. For the first requirement, add the current user range in the init method of the CustInvoiceJour datasource on the salesCopying Form(Path: Return order form > Find sales order)

    QuerybuildRange qbr; // Declare variable
    
    if (isCreditNoteHeaderOrLine) // Under this loop
        {
            onlyInvoiceAccount = queryBuildDataSource.addRange(fieldNum(CustInvoiceJour, InvoiceAccount));
            if (callerSalesTable.returnItem())
            {
                rangeSalesId = queryBuildDataSource.addRange(fieldNum(CustInvoiceJour, SalesId));
                rangeInvoiceDate = queryBuildDataSource.addRange(fieldNum(CustInvoiceJour, InvoiceDate));
                // Added code
                qbr = SysQuery::findOrCreateRange(queryBuildDataSource, fieldNum(CustInvoiceJour, CreatedBy));
                qbr.value(queryValue(curUserId()));
            }
        }

    2. Second requirement, add the current user range to the method initializeQuery of class ReturnTableListPageInteraction.

    public void initializeQuery(Query _query)
    {
        Query query;
        QueryBuildDataSource qbds;
        QueryBuildRange qbr;
    
        if (EP::isCustomer())
        {
            EPQuery::makeMyCustomerSelfServiceQuery(_query,tablenum(SalesTable));
        }
    
        // Added code
        qbds = _query.dataSourceTable(tableNum(salesTable));
        qbr = SysQuery::findOrCreateRange(qbds, fieldNum(salesTable, CreatedBy));
        qbr.value(queryValue(curUserId()));
    
        super(_query);
    }

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!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 26

#2
imran ul haq Profile Picture

imran ul haq 8

#3
André Arnaud de Calavon Profile Picture

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

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans