Skip to main content

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_allsl"vartanaKey"]; alert(test);</script>


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

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