Solved

Passing server side values into JavaScript function

  • 20 March 2021
  • 2 replies
  • 27 views

Hi,

I need to write a JavaScript function to process an external request. For which I need to pass some values such as session, cookie, DB values, from server side into the JavaScript function.

However, I am not sure how can I pass these values from the server side after processing into javascript function. I have added a PXTextEdit control 

<px:PXTextEdit ID="UsrSessionCookie" runat="server" Size="XL" DataField="UsrSessionCookie" Visible="False" />

which I though I can use to read the values using below syntax into JavaScript but I am not able to get it if I make these PXTextEdit Visible="False".

px_alls['UsrSessionCookie'].getValue();

I have also tried below to get values but no luck-

document.getElementById("ctl00_phF_form_UsrSessionCookie");

Also, I have to make sure that server side code executes first which will get all required values and then process the JavaScript request.

Any suggestions?

Thank you

icon

Best answer by KrunalDoshi 23 March 2021, 19:22

Thanks Gabriel,

Putting control in hidden div will also work. I tried to hide it from graph, using

 PXUIFieldAttribute.SetVisible

and, it worked to.

View original

2 replies

Userlevel 6
Badge +6

Hi Krunal,

When you set Visible=false the control is not rendered at all. I had a similar requirement a long time ago and ended up leaving the control visible, but I put it inside a hidden div - something like that: <div style="display:none">

I’m pretty sure there’s a cleaner way to do that but documentation on this topic is non-existing...

Thanks Gabriel,

Putting control in hidden div will also work. I tried to hide it from graph, using

 PXUIFieldAttribute.SetVisible

and, it worked to.

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