Home > Mobile >  Acumatica2021R2 CreateSalesOrder action is not defined in OpportunityMaint
Acumatica2021R2 CreateSalesOrder action is not defined in OpportunityMaint

Time:11-18

In the new version Acumatica 2021R2, the function CreateSalesOrders is not defined in OpportunityMaint graph, and I need add default values from Products to Solines in the olders version this it work but now I get error the function doesn't exist in the graph, I see that function exist in PX.Objects.CR.Extensions.CRCreateSalesOrder but is an abstract class and I don't find an implementation or this is in metadata

Old code

public delegate IEnumerable createSalesOrder(PXAdapter adapter);

[PXOverride]
public virtual IEnumerable CreateSalesOrder(PXAdapter adapter, createSalesOrder baseMethod)
{
    PXTrace.WriteInformation("try ");

    PXGraph.InstanceCreated.AddHandler<SOOrderEntry>((graph) =>
    {
        graph.RowInserted.AddHandler<SOOrder>((sender, e) =>
        {
            SOOrder order = (SOOrder)e.Row;
            SOOrderExt orderExt = PXCache<SOOrder>.GetExtension<SOOrderExt>(order);

            orderExt.UsrCustomOne = "Howdy";  //assign anything you want here*/
        });
    });

    return baseMethod(adapter);
 }

But this raises an error

The actions is not defined in the Graph OpportunityMaint

Now the action is in an abstract class CRCreateSalesOrder

CodePudding user response:

It's a generic graph, In OpportunityMaint you will see a line like

public class CRCreateSalesOrderExt : CRCreateSalesOrder<OpportunityMaint.Discount, OpportunityMaint, CROpportunity>

This extends the abstract generic graph and applies it's logic(including the createSalesOrder action) to the OpportunityMaint graph.

You should be able to override it with something like:

    public class CRCreateSalesOrderExt_Ext: PXGraphExtension<CRCreateSalesOrderExt, OpportunityMaint>
    {
        public static bool IsActive() => true;

        public delegate IEnumerable createSalesOrderDelegate(PXAdapter adapter);

        [PXOverride]
        public IEnumerable createSalesOrder(PXAdapter adapter, createSalesOrderDelegate baseMethod)
        {
            //Add your handler here

            return baseMethod(adapter);
        }
    }

CRCreateSalesOrderExt comes from the PX.Objects.CR.OpportunityMaint(defined on the graph) and is the graph extension that inherits from the generic graph CRCreateSalesOrder, and OpportunityMaint is the base graph.

  • Related