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 :
Finance | Project Operations, Human Resources, ...
Answered

Workflow recall doesn't change status

(2) ShareShare
ReportReport
Posted on by 29

I have done a workflow in my project but I have a problem when I click recall button it doesn't change the line status into draft again I tried to add an event handler class

final class CFM_Workflow_EventHandler

{

    

    [FormControlEventHandler(formControlStr(WorkflowStatus, WorkflowStatusCancel), FormControlEventType::Clicked)]

    public static void WorkflowStatusCancel_OnClicked(FormControl sender, FormControlEventArgs e)

    {

        FormRun formRun = sender.formRun();

        // Get the current record from the form's data source

        FormDataSource workflowTrackingStatusTable_ds = formRun.dataSource(formDataSourceStr(WorkflowStatus, WorkflowTrackingStatusTable));

        WorkflowTrackingStatusTable workflowTrackingStatusTable = workflowTrackingStatusTable_ds.cursor();

        // Retrieve the correlation ID

        WorkflowTrackingStatusTable trackingTable;

        select firstonly CorrelationId from trackingTable

        where trackingTable.InstanceNumber == workflowTrackingStatusTable.InstanceNumber;

        if (trackingTable.CorrelationId)

        {

            // Cancel the workflow

            Workflow::cancelWorkflow(trackingTable.CorrelationId, "Cancelled by user via Recall button");

            // Optional: Update your custom table status

            ITRequestEqLine itRequestEqLine;

            select forupdate itRequestEqLine

            where itRequestEqLine.InstanceNumber == workflowTrackingStatusTable.InstanceNumber;

            if (itRequestEqLine)

            {

                ITRequestEqLine::updateWorkflowStatus(itRequestEqLine.RecId, WorkflowLineStatusCFM::Draft);

            }

            info("Workflow has been successfully recalled.");

        }

        else

        {

            warning("Unable to find a valid workflow correlation ID.");

        }

    }

}

after I applied it the recall button became dimmed

Categories:
I have the same question (0)
  • Adis Profile Picture
    5,717 Super User 2025 Season 2 on at
    Microsoft dynamics 365 f&o issue
    Hi,
     
    Unfortunately, I cant give you advise as I am not a developer.
     
    However, have you checked how it works with the standard workflows that provide the recall button?
     

    Kind regards, Adis

     

    If this helped, please mark it as "Verified" for others facing the same issue

    Keep in mind that it is possible to mark more than one answer as verified

  • Verified answer
    Jonas "Jones" Melgaard Profile Picture
    4,894 Super User 2025 Season 2 on at
    Microsoft dynamics 365 f&o issue
    Moved from the General forum to the Finance forum
     
    Are you sure if you hit the "ITRequestEqLine::updateWorkflowStatus(itRequestEqLine.RecId, WorkflowLineStatusCFM::Draft);" line? You can check in the debugger.
     
     

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 1,841

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 490 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans