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)
Answered

Workflow status update in X++

(0) ShareShare
ReportReport
Posted on by

Hello All,

My workflow status isn't updating even after this method. I dont know what the problem is.

public server static void completeFromWorkflowEvent(RecId _recId)
{
#OCCRetryCount

SalesTable salesTable
;

try
{
// Every update must check the most current workflow approval status.
salesTable = SalesTable::findRecId(_recId, true);
//
// Validate that the current state allows for a transition to "Approved".
// "PendingApproval" is ok for transition to "Approved".
// If status is already "Approved" ignore the request.
//
if (salesTable.ReturnOrderApprovalStatus == LedgerJournalWFApprovalStatus::None ||
salesTable.ReturnOrderApprovalStatus == LedgerJournalWFApprovalStatus::NotSubmitted ||
salesTable.ReturnOrderApprovalStatus == LedgerJournalWFApprovalStatus::Submitted ||
salesTable.ReturnOrderApprovalStatus == LedgerJournalWFApprovalStatus::ChangeRequested)
{
// An invalid status change has been detected.
ReturnlWFApprovalStatusManager::invalidWorkflowStatusChangeError();

// throw error(strfmt("@SYS107962", ledgerJournalTable.JournalName, ledgerJournalTable.JournalNum));
}
else if (salesTable.ReturnOrderApprovalStatus == LedgerJournalWFApprovalStatus::PendingApproval)
{
salesTable.ReturnOrderApprovalStatus = LedgerJournalWFApprovalStatus::Approved;
ttsbegin;
salesTable.update();
ttscommit;
}

}

catch (Exception::Deadlock)
{
if (xSession::currentRetryCount() >= #RetryNum)
{
throw Exception::Deadlock;
}
else
{
retry;
}
}
catch (Exception::UpdateConflict)
{
if (appl.ttsLevel() == 0)
{
if (xSession::currentRetryCount() >= #RetryNum)
{
throw Exception::UpdateConflictNotRecovered;
}
else
{
retry;
}
}
else
{
throw Exception::UpdateConflict;
}
}
}

*This post is locked for comments

I have the same question (0)
  • Jonathan  Halland Profile Picture
    11,310 on at

    Hi. Can you maybe give some background as to what you are doing? Is your workflow running on the Sales Order correctly. Have you linked up your Actual Event handler on your sales order workflow to call this method and linked your workflow approval node to call your event handler.

  • Community Member Profile Picture
    on at

    @Jonathan, thanks. I am trying to create a return order workflow. The workflow is working but when it is completed, the status does not change to approved

  • Verified answer
    Jonathan  Halland Profile Picture
    11,310 on at

    Hi

    As above. have you done the following

    1. On your approval element, set the complete event handler to a valid event handler class

    2. In your event handler's complete method do you call the above method and do you call it with a valid recId?

  • Community Member Profile Picture
    on at

    @Jonathan, Thanks a lot. Number one questn solved it.

  • Community Member Profile Picture
    on at

    I have got the same problem. Event handler for approved is not being called.

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
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans