Skip to main content
Question

How can I create a dynamic graph extension

  • June 24, 2022
  • 4 replies
  • 336 views

aaghaei
Captain II
Forum|alt.badge.img+10

I have a generic graph extension that I would like to get the extensions dynamically. For example I want dynamically get “TGraph” & “_” & “Extension”.

 

The TGraph is dynamic based on the base graph but the extension is fixed.

4 replies

aaghaei
Captain II
Forum|alt.badge.img+10
  • Author
  • Captain II
  • June 24, 2022

CLARIFICATION

for example let say I am getting a graph ext like this

APInvoiceEntry_ApprovalWorkflow BaseAW = Base.GetExtension<APInvoiceEntry_ApprovalWorkflow>();

Now instead of “APInvoiceEntry_ApprovalWorkflow” I want dynamically replace the base graph part like this 

var graphExtensionName = $"{typeof(TGraph).Name}_ApprovalWorkflow";

how can I do this?


Chris Hackett
Community Manager
Forum|alt.badge.img
  • Acumatica Community Manager
  • July 26, 2022

Hi @aaghaei - were you able to find a solution for your issue? Thank you!


Hughes Beausejour
Acumatica Employee
Forum|alt.badge.img+2
  • Acumatica Developer Support Team
  • December 13, 2022

I found no way to do it so I had to iterate all extension and check for the one I need, example:
 

        private MyExtension<TGraph, TPrimary> GetTeamsGenericGraphExtension()
        {
            PXGraph graph = Base.TypelessClone();
            PXGraphExtension graphExt = null;
            MyExtension<TGraph, TPrimary> graphGenericExt = null;
            int i = 0;

            do
            {
                graphExt = graph.GetExtension(i++);
                graphGenericExt = graphExt as MyExtension<TGraph, TPrimary>;
            } while (graphExt != null && graphGenericExt == null);

            return graphGenericExt;
        }

 


aaghaei
Captain II
Forum|alt.badge.img+10
  • Author
  • Captain II
  • December 13, 2022

Hi @Hughes Beausejour @Chris Hackett 

I do really appreciate the response Hughes. What I ended up doing couple of months ago when I was working on this, was to write a case Method to check the Base Graph and return the expected Extension.

i have already implemented and tested the project I was working on it but I will utilize your suggested method next time I come across similar issue to see how it works. Considering we should have a very limited number of extension records, the loop shouldn’t pose performance degradations.

Thanks again.