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 :
Microsoft Dynamics AX (Archived)

Update field while approving by workflow?

(0) ShareShare
ReportReport
Posted on by 2,172

Hi All,

I want to update field while i select approve in workflow, I used the update method on my table linked with workflow, but the update method is not working in workflow. There is no other error. please help me with this.

*This post is locked for comments

I have the same question (0)
  • Jonathan  Halland Profile Picture
    11,310 on at
    RE: Update field while approving by workflow?

    Hi Anand I suspect you have added the amount code change after the status change. Only the status change code resides in the CIL and not your new code.

  • Anand AX Profile Picture
    2,172 on at
    RE: Update field while approving by workflow?

    Hi jonathan,

    Thank you so much for reply,

    1. I am struggling with this issue for past 2 days.

    2. Yes, The status is changing to approved.

    3. I did not try full CIL, I will try now

  • Suggested answer
    Jonathan  Halland Profile Picture
    11,310 on at
    RE: Update field while approving by workflow?

    Hi Anand. You will not get the infolog as this method is executed under batch processing.

    Just some notes.

    1. It may take a few minutes for the batch to execute this statement. It will not happen immediately.

    2. Does your status change to Approved?

    3. Check that you have done an incremental CIL compile subsequent to completing your code change.

  • Anand AX Profile Picture
    2,172 on at
    RE: Update field while approving by workflow?

    Hi Jonathan,

    I am not getting updated Approved Amount even after approving by workflow in the listpage form. So to check whether the code is working or not,I used info statement in the update method, its not showing infolog while running. how to rectify this?

  • Jonathan  Halland Profile Picture
    11,310 on at
    RE: Update field while approving by workflow?

    Hi Anand, your event looks correct. What errors or issues are you actually getting?

  • syed baber Profile Picture
    11,633 on at
    RE: Update field while approving by workflow?

    Hi Anand,

    The code looks correct. Similar code is being written in setWorkflowState method of CustInvoiceTable. You can take a look at that for your reference.

    Thanks,

    Baber.

  • Anand AX Profile Picture
    2,172 on at
    RE: Update field while approving by workflow?

    Hi Baber Owais,

    Thanks for the reply, As you said, I have given the code already, For your reference i am sharing it below,

    In SampleApprovalEventHandler class in approved method i used the below code,

    public void completed(WorkflowElementEventArgs _workflowElementEventArgs)

    {  Sampletable::UpdatesampleWorkflowState(_workflowElementEventArgs.parmWorkflowContext().parmRecId(), sampleReqWorkflowState::Approved);

    }

    and in sample table i used the below update method(UpdatesampleWorkflowState).

    public static void UpdatesampleWorkflowState(RefRecId _recId, sampleReqWorkflowState _state)

    {

           sampletable sample = sampletable::findRecId(_recId, true);

           ttsBegin;

           sample.Status = _state;

           if(_state == sampleReqWorkflowState::Approved)

           {

               sample.ApprovedAmount = sample.RequestedAmount;            

           }

           sample.update();

           ttsCommit;

     }

    Is that correct?? please clarify me!!

  • Suggested answer
    syed baber Profile Picture
    11,633 on at
    RE: Update field while approving by workflow?

    Hi Anand,

    In your approval event handler class SampleApprovalEventHandler, started method, write the code to update the field you want. Take a look at \Classes\CustFreeInvoiceWFApprovalEventHandler\started method for an example. This is the workflow approval event handler class for free text invoice document.

    Please try and let me know how it goes.

    Thanks,

    Baber.

  • Anand AX Profile Picture
    2,172 on at
    RE: Update field while approving by workflow?

    Hi Jonathan,

    Thanks for the reply, As you said, i checked there, its already selected with event handler only.  

    Event Handler : SampleApprovalEventHandler

  • Suggested answer
    Jonathan  Halland Profile Picture
    11,310 on at
    RE: Update field while approving by workflow?

    Hi Anand. You need to use the workflow eventhandlers for you workflow approval to achieve this. You can find the class by locating the Approval workflow node in the AOT, expanding the outcomes, click on Approve, Right click, click properties. There is an EventHandler property there.

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 2 Most Valuable Professional

#1
Guy Terry Profile Picture

Guy Terry 2 Moderator

#1
Community Member Profile Picture

Community Member 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans