Can we read the common or runtime config to get the Pega Server url in robotics.

Hi,

I have created a robotics(RDA) application where we are consuming data through a service and creating instances in our Pega application with that,but the url of the service we are consuming is hardcoded in the solution.Therefore, we are constantly changing the url when need to switch environments in various stages of our development cycle.

I am aware that we can read an xml document in robotics,but is it possible to get the Pega Server URL from the Common or runtime config so that I can switch the service url dynamically based on the environment the pega server is pointed to in those config files.

I have added the screenshot of the common config and highlighted the element I am attempting to read.

PS: We do not want to add a separate config file just for this,so trying to read through the existing config files.

Any advice would be much appreciated.

Thank you,

Megha

@MeghaSinha You can get the path to the file by using a static method from the Global Assembly cache (in the MSCORLIB assembly under Environment) called GetFolderPath. The SpecialFolder is called “CommonApplicationData”. This returns the path to %ProgramData% which you can combine with Pega systems to get the directory where the CommonConfig.xml would be. It appears from your post this is all you need, however if you want me to add an example of how to get that exact part from the XML, let me know.

Project91.zip (14 KB)

@ThomasSasnett

Hey Thomas,

Thank you for your prompt response.

I am actually trying to get the “Pega server url” that is provided in the server configurations part of the common config.Is there a way to read that.I tried using single node method of XMLDocument but it didn’t work.

I have also attached the screenshot of that part of the XML,the url is hidden but that’s what I am trying to read.

Let me know if that helps you understand my query.

Thank you,

Megha

@MeghaSinha Is this what you are looking for? To use the XMLDocumentComponent, you first load the file. After that, you can select the node you like using an XPath expression. Check out W3Schools website if you want a good (and quick) tutorial on XPath. Once you select the node, you can extract a proxy to operate on that node and call the GetAttribute method to get the baseURL attribute of that node.

In the attached solution, I am showing the Robot Inspector. You can switch to the Global Variables tab to see the values.

Project91_0.zip (19.1 KB)

@MeghaSinha There are two straightforward ways to do what you are interested in and neither use parsing the CommonConfig.

  1. The RobotManagerRestClient will automatically use the Robot Manager connection from the CommonConfig. If that is the desired Url then just switch from using the RestClient to using the RobotManagerRestClient. In your case that may not be so, so move on to #2.
  2. Use a configurations. Add a configuration item for each environment and set the Url there. You can set a variable to receive the Url and then use that variable in your Api calls.

More info on configurations can be found here: https://help.roboticautomation.pega.com/191/#t=project_configuration_and_deployment%2Fadd_configuration_item2.htm&rhsearch=configuration&rhhlterm=configuration%20configurations%20configure

More info on the RobotManagerRestClient can be found here: https://help.roboticautomation.pega.com/191/#t=components%2Frobot_manager_rest_client.htm&rhsearch=RobotManagerrestclient&rhhlterm=robotmanagerrestclient