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?
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.
@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 objectc] { 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();
});
}
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)
Hi @tylerstump09 were you able to find a solution? Thank you!
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.