Question

Auto Cancel QT based on Opportunity Lost status

  • 28 January 2022
  • 4 replies
  • 54 views

Userlevel 1
Badge

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

 

Thanks,
Idrus


4 replies

Userlevel 2
Badge +1

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

Userlevel 1
Badge

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

@idrusm52 

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)]
        [OpportunityWorkflow.States.List]

        
        public virtual string UsrCROpportunityStatus
        {
            get
            {
                return _UsrCROpportunityStatus;
            }
            set
            {
                _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)
return;
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

Reply


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 — 2022  Acumatica, Inc. All rights reserved