Skip to main content
Answer

Converting Quote to Sales Order

  • August 20, 2024
  • 6 replies
  • 258 views

Attempting to convert a sales quote to a sales order and I’m running into a blocker when trying to call DoCreateSalesOrder saying that I need to pass in a document of type CRCreateSalesOrder.Document

Here’s what I have so far:

var quoteGraph = PXGraph.CreateInstance<QuoteMaint>();
var soGraph = PXGraph.CreateInstance<SOOrderEntry>();

var quote = quoteGraph.Quote.Search<CRQuote.quoteNbr>(quoteNbr, opportunityId)
.RowCast<CRQuote>().First();

var filter = new CreateSalesOrderFilter
{
OrderType = "SO",
MakeQuotePrimary = false
};
var filterExt = filter.GetExtension<CRCreateSalesOrderFilterExt>();
filterExt.AMCopyConfigurations = true;

var quoteGraphExt = quoteGraph.GetExtension<QuoteMaint.CRCreateSalesOrderExt>();

quoteGraphExt.DoCreateSalesOrder(soGraph, quote, filter);

Appropriate any help or insight!

Best answer by tylerstump09

I ended up writing custom code that directly creates the SO based on the data from the Opportunity and Quote instead of using the convert process. So not a direct solution to this issue, but made it past that sticking point at least.

 

6 replies

Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • August 20, 2024

Hi @tylerstump09  In the Sales Quote screen, we already have button “Create Sales Order” to create Quote to Sales Order.

As you writing the logic explicitly, can you please let us know when are you executing this logic?


  • Author
  • Freshman II
  • August 20, 2024

Hi @Naveen Boga!

An outside service using a webhook will pass in the QuoteNbr and OpportunityID, which calls this method to create a sales order using that data.
 


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • August 20, 2024

@tylerstump09  Thanks for sharing the details.

Can you please try with the below code? I have done this a way long back and working fine.

 

Customer customer = PXSelect<
Customer,
Where<
Customer.bAccountID, Equal<Current<Document.bAccountID>>>>
.SelectSingleBound(Base, new object[] { Base1.DocumentView.Current });


if (customer == null)
{
throw new PXException(PX.Objects.CR.Messages.ProspectNotCustomer);
}

if (Base1.CreateOrderParams.AskExtFullyValid((graph, viewName) => { Base1.CreateOrderParams.Current.OrderType = "SO"; }, DialogAnswerType.Positive))
{
Base.Actions.PressSave();

var graph = Base.CloneGraphState();
PXLongOperation.StartOperation(Base, delegate ()
{
var extension = graph.GetProcessingExtension<CRCreateSalesOrder<OpportunityMaint.Discount, OpportunityMaint, CROpportunity>>();

extension.DoCreateSalesOrder();
});

}

 


  • Author
  • Freshman II
  • August 20, 2024

Appreciate the example!

It looks like this uses the opportunity context to create the sales order. I should have mentioned that the opportunity will have multiple quotes, so somehow it needs to be aware of which quote to use to create the sales order, unless I’m totally not following what’s happening (which is also very possible)


Chris Hackett
Community Manager
Forum|alt.badge.img
  • Acumatica Community Manager
  • September 10, 2024

Hi @tylerstump09 were you able to find a solution? Thank you!


  • Author
  • Freshman II
  • Answer
  • September 12, 2024

I ended up writing custom code that directly creates the SO based on the data from the Opportunity and Quote instead of using the convert process. So not a direct solution to this issue, but made it past that sticking point at least.