Is it possible to reference an Environmental Variable with JavaScript alone?

  • 7 March 2019
  • 1 reply
  • 1 view

I know it's probably not a good idea to edit the global ASPX pages of K2,
But it worked out really well when I threw the Google Analytics script in there. Now I can globally track every form that is visited.

Here is a bit of HTML code that renders a very thin Yellow stripe at the very top and it shows some text.

<div style="background-color:#fffdde;height:15px;border:thin solid #eddd00;position:fixed;top:0;left:0;right:0;";width:100%;padding:0px;></ul><li style='font-size:11px;text-align:center;vertical-align:middle;font-family:Verdana'>IMPORTANT: This platform will be undergoing maintenance soon. It will be unavailable from 3PM  to 5PM tomorrow</li></ul></div>

I was wondering if I could get the content of a miscelaneous Environmental Variable and display it.

Let me know if someone has tried something similar


1 reply

Hi,


 


If you are on K2 Five, you can enable REST access for this SmartObject called "Environment Field". That should allow you to use Javascript to access the SmartObject via REST.


 


The Environment Field SmartObject requires at least the EnvironmentId, and you can retrieve it by querying the [Environment].[Environment] table on your K2 database. The EnvironmentId for your Development and Production environment library should be fixed, so you should be able to hardcode it your Javascript.


 


Please note I have not tried this before, so I am not sure if this will work, but theoreotically speaking, it should work.


 


 


 

Reply