CRUD Operations in CodeX Script Using ConfigStore | Online Help | Qntrl | ConfigStore

Parameters in CodeX Script

In the CodeX script, you can perform CRUD (Create, Read, Update, Delete) operations on the Parameters in Qntrl through the SDK. Instead of defining a URL or other values directly in your CodeX script, you can define them in ConfigStore and reference those values in CodeX using parameter names. This approach promotes re-usability and simplifies updates. Discover more about CodeX Script.

How to Use ConfigStore in CodeX Script

  • Define Parameters in ConfigStore: Create and store the required parameters, such as URLs or API keys.
  • Reference Parameters in Codex Script: Use parameter names or link names to refer to values stored in ConfigStore. For example, reference the api_url parameter in your CodeX script using {{api_url}}.
  • CRUD Operations: Use the SDK to perform Create, Read, Update, and Delete operations on parameters stored in ConfigStore directly from your codex script.


Methods to Call Parameters

  1. Using Parameter Name: Requires both the parameter name and group name.

    • QntrlParam.ofName(paramName, paramGroupName)

  1. Using Parameter Link Name: Requires the parameter link name.

    • QntrlParam.ofLinkName(paramLinkName)

  1. Using Parameter ID: Requires the parameter ID.

    • QntrlParam.of(paramID)

 

Example

// Instead of hardcoding the URL, reference it from ConfigStore
let apiUrl = QntrlParam.ofLinkName("api_url"); 
// Use the referenced URL in your CodeX script
let httpReq = new HttpRequest(); 
httpReq.url(apiUrl);
httpReq.method("GET");
httpReq.headers("{ 'Content-Type': 'application/json' } ");
let httpRes = httpReq.execute();

 

CRUD Operations in CodeX

Create Parameter

To create a parameter, the name and value are mandatory. If the group is not specified, it defaults to 'none'. If the scope is not given, it defaults to 'global'. The encrypted parameter defaults to false.     
Syntax
QntrlParam.create("<param name>", "<group name>", true/false, QntrlParam.Scope.<GLOBAL/ENV>, "<param value>", "<default value>");

Read Parameter

You can retrieve parameter details using the parameter name, link name, or ID. This allows you to get all the parameter details, such as name, ID, scope, etc.

Get Parameter by Name  

Syntax
var param = QntrlParam.ofName("<param name>", "<group name>");

Notes
When retrieving a parameter by name, you must specify the group name. If the group name is not provided, it defaults to the default group. If the parameter is not found in the specified group, an error will be thrown.

Get Parameter by ID  

Syntax
var param = QntrlParam.of("<param ID>");

 

Syntax
var param = QntrlParam.ofLinkName("<link name>");

 

Update Parameter     

Syntax
param.update("<param name>", "<param value>", false, QntrlParam.Scope.<scope>, "<default value>");

 

Delete Parameter     

Syntax
param.destroy();