Auto Cancel QT based on Opportunity Lost status

  • 28 January 2022
  • 4 replies

Userlevel 2

Please advise how to make Customize or Workflow Action for Auto Canceling QT when Opportunity Status change to Lost.



4 replies

Userlevel 3
Badge +1

@idrusm52 are you talking about Sales Quote, Project Quote or Quote Type Sales Order?

Userlevel 2

Hi @samvellaHBl7QVBU6C6KqXsC79Q 

It’s Sales Order Quote Type.

Reclamation is typically done in the application's fundamental() work. Check in the event that QGuiApplication::isSessionRestored() is valid...

Userlevel 5
Badge +2


You can synchronise an opportunity status with a sales order by means of the following unbound field in SOOrder:

public class SOOrderOpportunityStatusExt : PXCacheExtension<SOOrder>
        public abstract class usrCROpportunityStatus : PX.Data.BQL.BqlString.Field<usrCROpportunityStatus> { }
        protected string _UsrCROpportunityStatus;
        [PXString(1, IsFixed = true)]
        [PXUIField(DisplayName = "Opportunity Status", Visibility = PXUIVisibility.SelectorVisible, Enabled = false)]

        public virtual string UsrCROpportunityStatus
                return _UsrCROpportunityStatus;
                _UsrCROpportunityStatus = value;



you can calculate its value on the grid of SO501000 screen (where you should add this field)

public virtual void SOOrder_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
if (Base.Filter.Current.Action != SOCreateShipment.WellKnownActions.SOOrderScreen.CancelOrder)
SOOrder row = (SOOrder)e.Row;

//PXFormulaAttribute.Evaluate<SOOrderOpportunityStatusExt.usrCROpportunityStatus>(sender, orderExt);
if (row == null) return;

CRRelation cRRelation = (CRRelation)PXSelectReadonly<CRRelation, Where<CRRelation.refNoteID, Equal<Required<CRRelation.refNoteID>>,
And<CRRelation.refEntityType, Equal<Required<CRRelation.refEntityType>>,
And<CRRelation.role, Equal<Required<CRRelation.role>>>>>>.Select(Base, row.NoteID, row.GetType().FullName, CRRoleTypeList.Source);
if (cRRelation != null)
CROpportunity opportunity =
(CROpportunity)PXSelectReadonly<CROpportunity, Where<CROpportunity.noteID, Equal<Required<CROpportunity.noteID>>>>.Select(Base, cRRelation.TargetNoteID);
if (opportunity != null)
SOOrderOpportunityStatusExt orderExt = row.GetExtension<SOOrderOpportunityStatusExt>();
orderExt.UsrCROpportunityStatus = opportunity.Status;

(see the 

 for additional info of link of sales orders with opportunites)

Then you can select the Cancel Order action the SO501000 screen and filter the grid by the Opportunity status = Lost. 

I’m not sure this approach (filter by unbound field) works well with schedules though. You can set it up with this condition but I did not manage to make it process any records 

You might want to make this field db stored (bound), but then you need to figure out how to update this field on changing the opportunity status (which is workflow-driven field). I believe it is doable.

Let me know if the ‘unbound field approach’ does not work and you need further assistance


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2023  Acumatica, Inc. All rights reserved