Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Unanswered

Submitting purch order created using purchAUtoCreate_sales in X++ to workflow through code

(0) ShareShare
ReportReport
Posted on by

Hello folks,

I am using purchAutoCreate_Sales in x++ code to create the purch orders, it works fine and creates a PO.

However need to ensure that the  created PO is submitted to the workflow through the code.

Upon checking the workflow I found that type of workflow type  is VendInvoiceRecordingTemplate also found this URL but cannot figure out what should I replace custinvoiceTable for my workflow.

Initially I thought it should be vendinvoiceinfotable, however looks like that is not the correct table as none of the PO created via purchAutoCreate_Sales are creating recs in that vendinvoiceinfotable even after I manually confirm the PO.

Please suggest a solution.

Thanks

Mav

  • Sukrut Parab Profile Picture
    Sukrut Parab 71,673 Moderator on at
    RE: Submitting purch order created using purchAUtoCreate_sales in X++ to workflow through code

    There is vendor invoice journal workflow, vendor invoice workflow, vendor invoice line worklow etc. in AP module. Where do u see purchase invoice journal workflow ?

    Also note, if you enable vendor invoice automation all the invoices created through Data management as pending vendor invoices submitted automatically to the workflow using process automation, you can take a look at that as well.

  • Mav Profile Picture
    Mav on at
    RE: Submitting purch order created using purchAUtoCreate_sales in X++ to workflow through code

    Hello,

    Any update on this would be really helfpul.

    Thanks

    Mav

  • Mav Profile Picture
    Mav on at
    RE: Submitting purch order created using purchAUtoCreate_sales in X++ to workflow through code

    Its standard out of the box OOB purchase invoice journal workflow.

  • Sukrut Parab Profile Picture
    Sukrut Parab 71,673 Moderator on at
    RE: Submitting purch order created using purchAUtoCreate_sales in X++ to workflow through code

    The workflow you are trying to submit on PO is custom created workflow or are u using standard workflow ?Is its custom then you might have to add custom method which is going to be similar to custInvoiceTable which just sets the state on the workflow on the originating table.

  • Mav Profile Picture
    Mav on at
    RE: Submitting purch order created using purchAUtoCreate_sales in X++ to workflow through code

    Hello Sukrut,

    No problem, I am using VendInvoiceRecordingTemplate type workflow, which is accessible at  action pane workflow of purchase order.

    I am trying to replace the code from this link which is for custinvocetrans to that of purchtable.

    I am NOTfacing any challenge in selecting purchtable record , only challenge I am facing is how to replace below line of code with purchtable as I am unable to find any setWorkflowState() or similar function at purchtable.

    "custInvoiceTable::setWorkflowState(_custInvoiceTable.RecId, CustFreeInvoiceWFApprovalState::Submitted); "

    Thanks

    Mav

  • Sukrut Parab Profile Picture
    Sukrut Parab 71,673 Moderator on at
    RE: Submitting purch order created using purchAUtoCreate_sales in X++ to workflow through code

    Sorry , I did not understand what is missing.  Can you please explain which workflow you are using and what kind of challenges you have for selecting puchtable record.

  • Mav Profile Picture
    Mav on at
    RE: Submitting purch order created using purchAUtoCreate_sales in X++ to workflow through code

    Hello Sukrut,

    Yes that was done.

    Only thing pending is to replace below line of code with Purchtable and I coulld not find any setWorkflowState() or similar in Purctable code.

    custInvoiceTable::setWorkflowState(_custInvoiceTable.RecId, CustFreeInvoiceWFApprovalState::Submitted);

    Thanks

    Mav

  • Sukrut Parab Profile Picture
    Sukrut Parab 71,673 Moderator on at
    RE: Submitting purch order created using purchAUtoCreate_sales in X++ to workflow through code

    Hi Mav , 

    Did you try using method  activateFromWorkflowType  from class workflow to submit PO to workflow? Check code below, recId parameter should be the recId of Purchtable. 

    //Activate the workflow
    Workflow::activateFromWorkflowType(workFlowTypeStr(YourWorkflow), recId, "@AccountsPayable:VendChangeProposalSubmit_SubmittedMessage", NoYes::No);

  • Mav Profile Picture
    Mav on at
    RE: Submitting purch order created using purchAUtoCreate_sales in X++ to workflow through code

    Hello  all,

    Anyone any update on this would be helpful.

  • Mav Profile Picture
    Mav on at
    RE: Submitting purch order created using purchAUtoCreate_sales in X++ to workflow through code

    Hello Andre,

    Any update on above would be helpful.

    Thanks

    Mav

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

Announcing Our 2025 Season 1 Super Users!

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

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,971 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,846 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans