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

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Sales order confirmation using AIF

(0) ShareShare
ReportReport
Posted on by 65

Hi,

I've wrote a simple method in SalesSalesOrderService but it doesn't confirm the status of Salesorder rather it creates a new sales order and duplicates all the values including lines. Following is my code.

[AifDocumentReadAttribute, SysEntryPointAttribute(true)]
public boolean confirmSales(SalesId _salesId)
{
    SalesFormletter SalesFormletter;
    SalesTable SalesTable;

    try
    {
        SalesFormletter = SalesFormletter::construct(DocumentStatus::Confirmation);

        SalesTable = SalesTable::find(_salesId);

        SalesFormletter.update(SalesTable,
                                                  systemDateGet(),
                                                  SalesUpdate::All,
                                                  AccountOrder::None,
                                                  false,
                                                  false);


        return true;
    }
    catch(Exception::Error)
    {
        return false;
    }
}

I've also tried changing AifDocumentReadAttribute to AifDocumentUpdateAttribute but it still creates another order. I've testing the same code via job and it works.

Need your help guys. Thanks.

*This post is locked for comments

I have the same question (0)
  • Martin Dráb Profile Picture
    236,570 Most Valuable Professional on at
    RE: Sales order confirmation using AIF

    Either debug your code or show us what you're calling, because you seem to be calling different code than you think.

  • Sukrut Parab Profile Picture
    71,699 Moderator on at
    RE: Sales order confirmation using AIF

    I don't think above code is going to create new SO unless something different is getting called.

  • Muhammad Zain Ul Abiddin Profile Picture
    65 on at
    RE: Sales order confirmation using AIF

    Hi Martin,

    I've wrote the following code in a .Net application.

    SalesOrderServiceClient axClient = new SalesOrderServiceClient();
    CallContext callcontext = new CallContext();
    callcontext.Company = Config.company;
    callcontext.Language = Config.language;
    bool confirmSO = axClient.confirmOrder(callcontext, "SalesId");


    Furthermore, I've created other custom methods too and they are working fine and as i mentioned earlier if I ran the same code from within ax it works fine.

  • Muhammad Zain Ul Abiddin Profile Picture
    65 on at
    RE: Sales order confirmation using AIF

    Nothing different is calling, I've posted my code below. This is the strangest behavior I had in years. Can you please suggest another approach to confirm a sales order using .Net.

  • Muhammad Zain Ul Abiddin Profile Picture
    65 on at
    RE: Sales order confirmation using AIF

    One correction in the last line of code is Bold

    bool confirmSO = axClient.confirmSales(callcontext, "SalesId");

    I tried renaming the method after doing some changes to make sure they are being affected.

  • Martin Dráb Profile Picture
    236,570 Most Valuable Professional on at
    RE: Sales order confirmation using AIF

    You don't have top guess or renaming the method to see if it's used - please use the debugger to find out what's going on in your code.

  • Muhammad Zain Ul Abiddin Profile Picture
    65 on at
    RE: Sales order confirmation using AIF

    Sure, let me try that. I'll post afterwards.

  • Verified answer
    Muhammad Zain Ul Abiddin Profile Picture
    65 on at
    RE: Sales order confirmation using AIF

    Found out the problem, the sales order created from AIF was of type Journal. I changed that to sales order and tried my method again it worked like a charm. Thanks guys. 

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Tocauer Profile Picture

Martin Tocauer 4

#2
Community Member Profile Picture

Community Member 2

#2
Nayyar Siddiqi Profile Picture

Nayyar Siddiqi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans