◷ Reading Time: 6 minutes
If you want to pass parameter values to a package without adding them as an input or local parameter, you can use the package settings.
For example, if you want to add a password that you don’t want to be passed as an input or hard-code in the project as a local parameter, you can define it as a setting value.
- Parameter Name: Name of the parameter that holds the settings
- Name: Name of the setting
- Value: Value of the setting
How to Set Package Settings
Let’s see how you can add a connection string of a database as a setting.
1. In your project, add an Input parameter called
You can use any name (i.e. config, constants) although we used the name
Settings by default.
Settings.ConnectionString as the connection string.
You can add any name under
Settings although we used the name
There is no need to define the parameter name
Settings.ConnectionString in the designer project.
3. Then deploy your package in FlexRule server workbench.
4. Click on Settings under the package Actions column.
5. Add these
- Parameter Name: Settings
- Name: ConnectionString
- Value: <connection string to your database>
Data Source=.\SqlExpress01;Initial Catalog=customer;Trusted_Connection=True
6. Click on Add New Setting
7. Once you add all the settings, click on
Save to save the added settings.
8. Now run the service without adding Settings as an input parameter. In this example, we don’t have any other input parameters. Therefore, we pass an empty array
9. Now if you test run the project, you will see the settings have been assigned during runtime.
How to Test Settings in FlexRule Designer
You can test the Settings in FlexRule Designer before publishing it to the server. This will ensure that the setting values are correct.
- Click on Debug with JSON Composer.
2. Go to Text Mode
3. Edit the
Settings parameter to add
Connection String value and click OK (Note that
\ in the string should be replaced with
\\ in the Desinger).
You will be able to see the output in the Parameter window.
Setting Values as a Fact Concept
Additionally, if you have multiple settings, you can set the settings as a Fact Concept.
You can reference the settings from the fact concept as an input parameter.
Download Sample Project
The downloadable sample project is attached at the end of the page.
- This is the example explained under How to set package Settings
- To create the database, you can use the script, script.sql inside the folder.