Question

Trying to access a GraphExtension variable in my javascript function

  • 9 April 2024
  • 1 reply
  • 28 views

Hi, I am trying to access a variable in my graph extension from the script on my page, can someone please help me achieve this. Trying to build a URL in graph extension and sending it Javascript to render it in an iframe.

This is the code, where i want to access the key field from this GraphExtension in my javascript function 

#region Selects
public PXSelect<SOOrder> AllRecs;
#endregion

#region Event Handlers
#endregion

[PXString]
[PXUIField(DisplayName="API")]
public virtual String vartanaKey {get; set;}

public PXAction<SOOrder> VACreateOrder;
[PXButton]
[PXUIField(DisplayName = "Create Order")]
public virtual IEnumerable vaCreateOrder(PXAdapter adapter)
{
try
{
usrVAVartanaConfigGraph configGraph = PXGraph.CreateInstance<usrVAVartanaConfigGraph>();
VAVartanaConfig keyRec = configGraph.AllRecs.Select().FirstOrDefault();
vartanaKey = keyRec.UsrVAApiKey;
//throw new PXException(vartanaKey.UsrVAApiKey);
}
catch (Exception e) { throw new PXException(e.Message); }

return adapter.Get();
}



the corresponding script is added via a px:PXLiteral tag so this how it looks.

<script > var test = px_alls["vartanaKey"]; alert(test);</script>


What am i doing wrong here, can we access variables in GraphExtension somehow?


1 reply

Graph variables are cannot be directly accessed on the JavaScript.

Can you try creating a DAC field and controls for the specific value, on the screen? So the field can accessed using the ID assigned on aspx file of the screen.

 

 

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