web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
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 556
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
    556 on at
    Any idea?
  • Suggested answer
    Waed Ayyad Profile Picture
    9,212 Super User 2026 Season 1 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,212 Super User 2026 Season 1 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,212 Super User 2026 Season 1 on at
    Hi DELDYN,
     
    Does my suggestion help you?
  • Verified answer
    Layan Jwei Profile Picture
    8,266 Super User 2026 Season 1 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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 445 Super User 2026 Season 1

#2
Subra Profile Picture

Subra 407

#3
Martin Dráb Profile Picture

Martin Dráb 274 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans