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

How to submit "project quotation" workflow by code?

(0) ShareShare
ReportReport
Posted on by 482
Hi,

I'm creating a project quotation by code through a custom service. So after creating it, i would like to auto submit the workflow inside the service as well.


1. How can i do that via x++?
2. How can i add validation, to only go through this code, if the workflow button is there, i mean if someone deactivated the workflow, then no need to go through this code
I have the same question (0)
  • DELDYN Profile Picture
    482 on at
    Any idea?
  • Suggested answer
    Waed Ayyad Profile Picture
    9,039 Super User 2025 Season 2 on at
    Hi @DELDYN,
     
    You can use this code to submit the record to workflow by code, just change the information based on your table, and workflow type:(For Question 1)
    // submit to workflow
     ttsbegin;
    
     CustTable::updateWorkflowState(proposal.custTable, CustTableChangeProposalWorkflowState::Submitted);
    
     // Activate the workflow.
    
      Workflow::activateFromWorkflowType(workFlowTypeStr(CustTableChangeProposalWorkflow), proposal.custTable, "@AccountsReceivable:CustChangeProposalSubmit_SubmittedMessage", NoYes::No);
    
     ttscommit;
     
    Thanks,
    Waed

    Please mark this answer as "Verified" if it solved your issue. In order to help others who will face a similar issue in the future
     

  • Suggested answer
    Waed Ayyad Profile Picture
    9,039 Super User 2025 Season 2 on at
    Hi DELDYN,
     
    For the Question 2: 
     
    WorkflowVersionTable workflowVersion;
    workflowVersion = Workflow::findWorkflowConfigToActivateForType(userRequest.workflowType(), userRequest.RecId, tableNum(UserRequest));
    if (workflowVersion.Enabled)
    {
        Workflow::activateFromWorkflowConfigurationId(
                      workflowVersion.ConfigurationId,
                        userRequest.RecId,
                        workflowComment,
                        NoYes::No);
    }
    else
    {
        if (!workflowVersion || !workflowVersion.workflowTable())
        {
            workflowDisplayName = userRequest.workflowType();
        }
        else
        {
            workflowDisplayName = workflowVersion.workflowTable().Name;
        }
        throw error(strFmt("@GLS130222", workflowDisplayName));
    }
    
    Thanks 
    Waed Ayyad
    Please mark this answer as "Verified" if it solved your issue. In order to help others who will face a similar issue in the future
  • Waed Ayyad Profile Picture
    9,039 Super User 2025 Season 2 on at
    Hi DELDYN,
     
    Does my suggestion help you?
  • Verified answer
    Layan Jwei Profile Picture
    8,112 Super User 2025 Season 2 on at
    For project quotations,

    Here's the code needed:
    ttsbegin;
    WorkflowVersionTable workflowVersionTable;
    workflowVersionTable = Workflow::findWorkflowConfigToActivateForType(workFlowTypeStr(PSAProjQuotationTemplate), salesQuotationTable.RecId, tableNum(SalesQuotationTable));
    if (workflowVersionTable.Enabled)
    {
          PSAProjQuotationSubmitSend submitToWorkflow = new PSAProjQuotationSubmitSend();
    
          submitToWorkflow.parmWorkflowVersionTable(workflowVersionTable);
          submitToWorkflow.parmWorkflowComment("Add your comment here");
    
          PSAProjQuotationSubmitSend::submitToWorkflow(submitToWorkflow.parmWorkflowVersionTable().ConfigurationId, salesQuotationTable.RecId, submitToWorkflow.parmWorkflowComment());
    }
    ttscommit;

    Thanks,
    Layan Jweihan
    Please mark this answer as "Verified" if it solved your issue. In order to help others who will face a similar issue in the future

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 584 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 499 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 254 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans