Solved

Lifelong .NET developer really confused how to customize Convert Lead to Opportunity Action to set the Opportunity Class and automatically map related attributes

  • 5 July 2023
  • 2 replies
  • 108 views

I need to customize the Lead's “Convert to Opportunity” Action (convertToOpportunityAll) to map the Lead Class to the Opportunity Class and then als the related attributes.

I’m trying to create a LeadMaint Graph Extension in a Customization project in 2022 R2.

Problems:

1. When I try to Inspect the Element for the convertToOpportunityAll Action Button and click ACTIONS and choose CUSTOMIZE BUSINESS LOGIC it creates a Code file like this:

using PX.Data;
using PX.Data.BQL;
using PX.Data.BQL.Fluent;
using PX.Objects.AR;
using PX.Objects.CR.Extensions.CRDuplicateEntities;
using PX.Objects.CR.Extensions.SideBySideComparison;
using PX.Objects.CR.Extensions.SideBySideComparison.Merge;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using PX.Objects;
using PX.Objects.CR;

namespace PX.Objects.CR
{
  public class LeadMaint_Extension : PXGraphExtension<PX.Objects.CR.LeadMaint>
  {
    #region Event Handlers

    #endregion
  }
}

but when I click OVERRIDE METHOD there are no Methods listed for the convertToOpportunityAll Action...

Why is this missing? 


2. I dug around the Source Code and found a namespace PX.Objects.CR.Extensions.CRCreateActions with a method ConvertToOpportunityAll which looks like it should work.

I've tried to pair it down and create that as an extension for LeadMaint (as follows) but it has lots of Publish errors and I'm really not sure what to do next.

using PX.Data;
using PX.Data.BQL;
using PX.Data.BQL.Fluent;
using PX.Objects.AR;
using PX.Objects.CR.Extensions.CRDuplicateEntities;
using PX.Objects.CR.Extensions.SideBySideComparison;
using PX.Objects.CR.Extensions.SideBySideComparison.Merge;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using PX.Objects;
using PX.Objects.CR;

namespace PX.Objects.CR.Extensions.CRCreateActions
{
    public class CRCreateOpportunityAllAction_Extension : PXGraphExtension<CRCreateOpportunityAllAction, TGraph, TMaster, TOpportunityExt, TAccountExt, TContactExt>
    {
        [PXOverride]
        public delegate IEnumerable ConvertToOpportunityAll(PXAdapter adapter);
        [PXButton]
        [PXUIField]
        public IEnumerable ConvertToOpportunityAll(PXAdapter adapter, CRCreateOpportunityAllAction BaseMethod)
        {
            //Logic Here
           return BaseMethod.Invoke(adapter);
        }
    }
}

I and a colleague have spent a couple of days researching and watching training videos but nothing seems to show us how to implement this customisation?

Any help would be fantastic!

icon

Best answer by crowers 5 July 2023, 23:34

View original

2 replies

Userlevel 1
Badge

Hello @crowers 

Use below graph extension syntax and try to overide the

“public virtual void DoConvert(bool redirect)” method to send your values. I have not validated it, but you can give it a shot.

 public class CreateOpportunityAllFromLeadGraphExtExt : CRCreateOpportunityAllAction<LeadMaint, CRLead, CreateOpportunityFromLeadGraphExt, CreateAccountFromLeadGraphExt, CreateContactFromLeadGraphExt>
{
public static bool IsActive() => true;




}

 

Thanks so much @rajeshvemunoori31 for your help with that. It pointed me roughly in the right direction.

I managed to get it to compile with the following code:

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using PX.Common;
using PX.Data;
using PX.Data.BQL;
using PX.Data.BQL.Fluent;
using PX.Data.EP;
using PX.Data.MassProcess;
using PX.Data.UI;
using PX.Objects.AR;
using PX.Objects.CR.Extensions;
using PX.Objects.CR.Extensions.Cache;
using PX.Objects.CR.Extensions.CRContactAccountDataSync;
using PX.Objects.CR.Extensions.CRCreateActions;
using PX.Objects.CR.Extensions.CRDuplicateEntities;
using PX.Objects.CR.Extensions.PinActivity;
using PX.Objects.CR.Extensions.Relational;
using PX.Objects.CR.Extensions.SideBySideComparison;
using PX.Objects.CR.Extensions.SideBySideComparison.Merge;
using PX.Objects.CR.LeadMaint_Extensions;
using PX.Objects.CR.MassProcess;
using PX.Objects.CS;
using PX.Objects.GL;
using PX.Objects.IN;
using PX.SM;
using PX.TM;

namespace PX.Objects.CR
{
public class CreateOpportunityAllFromLeadGraphExt : CRCreateOpportunityAllAction<LeadMaint, CRLead, LeadMaint.CreateOpportunityFromLeadGraphExt, LeadMaint.CreateAccountFromLeadGraphExt, LeadMaint.CreateContactFromLeadGraphExt>
{
public static bool IsActive() => true;

public override void DoConvert(bool redirect) {

}
}
}

 

We are not impressed with Acumatica’s poor documentation and wildly over-complex customization code….  who’s idea was it do develop it like this?!!

I don’t know if it will hit the DoConvert function (haven’t tried yet) but I’ve no idea what to put in that function! 

This is what we need: when the Lead’s “Convert to Opportunity” Action is clicked we need to map the Lead Class to the Opportunity Class and then also the related attributes.

Does anyone know of any examples of this kind of Action override?

Many thanks again.

 

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