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 tell that sales order has been confirmed by calling the system classes from X++

(0) ShareShare
ReportReport
Posted on by

Hi Experts

I am using below code to confirm SO via X .

How can i tell that the below code has actually confirmed the SO  so that i can set a boolean ret  to true only if it has been confirmed .

Is there any out of box feature to check if order was confirmed successfully , if not then i guess the only way is to check custconfirmjour table like below. Please suggest if any other/better way available.

Class myclass
{
    public static boolean confirmSO(Salestable _salestable)
    {
        boolean ret;
        salesFormLetter = SalesFormLetter::construct(DocumentStatus::Confirmation);
        custconfirmjour custconfirmjour1,custconfirmjour2;
        
        
        select firstonly ConfirmId,SalesId ,CreatedDateTime from custConfirmJour1 
                order by CreatedDateTime desc
                where custConfirmJour1.SalesId == salesTable.SalesId;
                

        salesFormLetter = SalesFormLetter::construct(DocumentStatus::Confirmation);
        salesFormLetter.update(salesTable, DateTimeUtil::getSystemDate(DateTimeUtil::getUserPreferredTimeZone()), SalesUpdate::All);

        select firstonly ConfirmId,SalesId, CreatedDateTime from custConfirmJour2
            order by CreatedDateTime desc
            where custConfirmJour2.SalesId == salesTable.SalesId;
                

            if( custConfirmJour2.ConfirmId > custConfirmJour1.ConfirmId )
            {
                ret = true;
            }
        
        return ret
    }
}

Thanks

Mav

I have the same question (0)
  • André Arnaud de Calavon Profile Picture
    301,119 Super User 2025 Season 2 on at

    Hi Mav,

    The update() method does not return a result, so your coding will make sense. However, I would suggest one small change. You now check if the new ConfirmId is greater than the old ConfirmId. This might not work if there is a change in the number sequence. You can better check if the value is not equal to. ( != ).

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

    Call salesFormLetter.getOutputContract() to get information about the result.

    For example, you can check the number of posted orders:

    FormletterOutputContract outputContract  = purchFormLetter.getOutputContract();
    if (outputContract.parmNumberOfOrdersPosted() > 0)
    {
    	...
    }

  • Mav Profile Picture
    on at

    Thanks Martin, that approach using OOB methods works just fine  after making some adjustment to code like below.

    Sharing complete code to help others.

    Class CustomClass
    {
        public static boolean postSOCnfrm(SalesTable _salestable)
        {
             SalesFormLetter             salesFormLetter          = SalesFormLetter::construct(DocumentStatus::Confirmation);
             FormletterOutputContract    formLetterOutputContract = new FormletterOutputContract();
            
            
            salesFormLetter.update(_salestable, DateTimeUtil::getSystemDate(DateTimeUtil::getUserPreferredTimeZone()), SalesUpdate::All);
            formLetterOutputContract = salesFormLetter.getOutputContract();
            
            if(formLetterOutputContract.parmNumberOfOrdersPosted() > 0)
            {
            
                ret = true;
            }
                
            return ret;
        }
    }

    Regards

    Mav

  • Loz Saunders Profile Picture
    51 on at

    Hi Mav, thanks for posting your code; it saved me a ton of time figuring this out for myself

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 451 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans