Question

How can I create a dynamic graph extension

  • 24 June 2022
  • 4 replies
  • 267 views

Userlevel 7
Badge +9

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

Userlevel 7
Badge +9

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.

Userlevel 5
Badge +2

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;
        }

 

Userlevel 7
Badge

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

Userlevel 7
Badge +9

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?

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