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

X++ : Workflow Work Item Business event Payload Extension

(1) ShareShare
ReportReport
Posted on by
Hi All,
 
My goal is to extend the standard business event payload /BusinessEventWorkflowWorkItem/ so that I can add a list of previous steps in the WF.
 
I can create the methods to set the new fields, but I cannot extend the Initialize method, as you can see in the screenshot, with the message /The next cannot be invoked in the method /Initialize/ because it is not in a Cain Of Command method).
 
My first idea was also to extend the /BusinessEventWorkflowWorkItem/ class, specifically the buildContract() method, but it is Internal and therefore it is not possible to do so.
 
Has anyone ever faced a similar problem?
Do you have a solution to achieve my goal or do you suggest I create specific business events (with the desired payload) and launch them at the WFs I am interested in?
 
Thanks in advance, 
Luca
  • Suggested answer
    CU19081013-0 Profile Picture
    on at
    X++ : Workflow Work Item Business event Payload Extension
    Hi Martin,
     
    thanks to your suggestion, I revised the solution and opted to create a custom action in an entity to be able to retrieve this information.
    This way I will not burden the business event payload and will have the information on demand.
     
    The only cons of this solution might be slowing down the flow of Power Automate due to the execution of the action.
    Still, I think this is reasonable compared to burdening the payload of each business event for workflow work items.
     
    Do you know of any other cons to this that I am missing?
  • CU19081013-0 Profile Picture
    on at
    X++ : Workflow Work Item Business event Payload Extension
    My requirement is to provide the list of previous approvers within the mail that the current approver will receive.
    To do this, we thought of a Power Automate flow, triggered by the WF business event, which sends an email to the current approver, with this information.
     
    In your opinion and your experience, could it be easier and technically correct to create a special action to expose this information in the "WorkflowWorkItems" entity?
     
    In that way, the payload will remain the same and the information will be retrieved at the needed.
  • Martin Dráb Profile Picture
    231,758 Most Valuable Professional on at
    X++ : Workflow Work Item Business event Payload Extension
    construct() is public - I verified it. What I didn't notice was that the whole idea of extending this class can't work, because the class itself is internal.
     
    If I was you, I would think carefully whether your technical solution (adding previous steps to the payload) is the right approach to the business requirement. Payload should be lightweight and easy to populate. Consider keep it as it is and exposing a web service with additional details. When (only when) the business event is subscribed to and processed by someone who needs additional details, he'll call the web service to fetch them.
  • CU19081013-0 Profile Picture
    on at
    X++ : Workflow Work Item Business event Payload Extension
    Hi Martin,
     
    Thanks for the feedback. Yes I mean the BusinessEventsWorkFlowWorkItem class.
    An equivalent of this in BusinessEventsWorkFlowWorkItem is creating a method like initialize() and calling it from a CoC extension of construct().
    Ok for the Initialize method, but I cannot extend the construct() of the class, since it is an internal one. 
    Or did I get something wrong?
     
    After your answer, however, I start thinking about other solutions and my new idea is to create a new custom business event and trigger it in the same spot where the BusinessEventsWorkFlowWorkItem is triggered.
    Also there, the issue is that the methods that trigger this business event are private so I cannot develop my solution.
    Have you any suggestions also on this, please?
     
    Thanks in advance,
    Luca
  • Suggested answer
    Martin Dráb Profile Picture
    231,758 Most Valuable Professional on at
    X++ : Workflow Work Item Business event Payload Extension
    There is no BusinessEventWorkflowWorkItem class, but you surely mean BusinessEventsWorkFlowWorkItem class.
     
    It indeed doesn't have any initialize() method, therefore an attempt to extend it must fail.
     
    The article (in the part covering design of new business events) suggests creating initialize() method and calling it from a factory method (newFromCustInvoiceJour()). An equivalent of this in BusinessEventsWorkFlowWorkItem is creating a method like initialize() and calling it from a CoC extension of construct().

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,884 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,758 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans