Rocket Modern Experience (formerly LegaSuite)

 View Only

 Read deployment properties file and use in engine side javascript

VitheyaMonikha K J's profile image
VitheyaMonikha K J posted 07-11-2024 07:48

Hi,

I've configure the API url and headers in deployment.properties file in my workbench and try to read the values from deployment.properties file using engine side javascript  in Rocket MX 10.4.3. I couldn't get those values. I have a predefined function GetDeploymentProp method in VB script ,but I couldn't access it from engine side javascript. Can anyone give a solution for this?

Thanks,

Vitheya Monikha

Roger Van Valen's profile image
Roger Van Valen

Hi Vitheya,

The following JavaScript example shows how you can get either a single property from the properties file, or get all properties as an object:

import config from 'mx:config'

// Get a deployment property
console.log('example.name    : ' + config.deployment.example.name);
console.log('example.company : ' + config.deployment.example.company);
console.log('example.badentry: ' + config.deployment.example.badentry);

// Print all deployment properties
console.log(JSON.stringify(config.deployment, null, '  '));

When using the following contents in deployment.properties:

example.name=Roger
example.company=Rocket Software

it will give the following console output:

2024-07-15T11:16:09,272 [25724] INFO  javascript.console - example.name    : Roger 
2024-07-15T11:16:09,272 [25724] INFO  javascript.console - example.company : Rocket Software 
2024-07-15T11:16:09,272 [25724] INFO  javascript.console - example.badentry: undefined 
2024-07-15T11:16:09,272 [25724] INFO  javascript.console - {
  "example": {
    "name": "Roger",
    "company": "Rocket Software"
  }
} 

Hope this helps,

Regards,

Roger van Valen

VitheyaMonikha K J's profile image
VitheyaMonikha K J

Hi Roger Van Valen,

Thank you for your support, It works and I'm able to get the value from the deployment.properties file.  

Thanks,

Vitheya Monikha