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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Validation on workflow approval

(0) ShareShare
ReportReport
Posted on by 400

Hi All,

I want to do one validation before approve the workflow.

Example:

In my table I have a field called posted. So my validation is, if the record is posted then only system should allow to approve.

I tried to disable the workflow in form datasource active method but not worked.

public int active()

{

int ret;

ret = super();

if (TableA.Posted == NoYes::Yes)

{

element.design().workflowEnabled(true);

}

else

{

element.design().workflowEnabled(false);

}

return ret;

}

where can we write the code for this.

Either we can throw validation when we do approve or disable the approve button until the condition satisfies whatever is possible.

I have the same question (0)
  • Gunjan Bhattachayya Profile Picture
    35,423 on at

    Hi Satya,

    Once you submit the workflow the assigned user will be able to approve. In this case you can allow the record to be submitted to workflow only when it is posted.

    You can try the canSubmitToWorkflow method in your table for achieving this.

  • Creativesatti Profile Picture
    400 on at

    Hi Gunjan,

    Thanks for the reply.

    But in my business process. First submit the record to workflow, after some process record will be posted. Then it will go for approval. Due to this I can't use canSubmitToWorkflow.

    So I am looking for a way to write validation after submit and before approve the workflow.

  • Verified answer
    Blue Wang Profile Picture
    Microsoft Employee on at

    Hi Satya,

    Please try this:  daxtechsolutions.blogspot.com/.../d365ax7-add-validation-before-workflow.html

    Create a new class extends WorkflowWorkItemActionManager.

  • Suggested answer
    Creativesatti Profile Picture
    400 on at

    Hi Blue Wang,

    Thanks a lot for the help. It worked. but I changed the code little bit in main method and used preActionDialogRun() override method instead validate() method.

    Changes as follow.

    main method:

    public static void main(Args _args)

    {

     ChecklistWFActionManager taskWorkflowActionManager = new ChecklistWFActionManager();

    taskWorkflowActionManager.parmCaller(_args.caller());

    if(_args.record() && _args.record().TableId == tableNum(TableName))

    {

    taskWorkflowActionManager.parmArgs(_args);

    taskWorkflowActionManager.run();

    }

    else

    {

    throw error("Invalid action requested");

    }

    }

    preActionDialogRun

    protected void preActionDialogRun()

    {

    Common tabelRecord = args.record();

     

    if (Required condition)

    {

    throw error("Invalid transaction.");

    }

    super();

    }

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

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

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 658

#2
André Arnaud de Calavon Profile Picture

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

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 333 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans