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

Announcements

News and Announcements icon
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 41

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
    6,808 Super User 2026 Season 1 on at
    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
    5,016 Most Valuable Professional on at
    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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Abhilash Warrier Profile Picture

Abhilash Warrier 658 Super User 2026 Season 1

#2
André Arnaud de Calavon Profile Picture

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

#3
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 570

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans