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

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

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