This article contains several Graphit file examples. Graphit file names, when mentioned, refer to the files found in the KB Demo Project under Project Tree > Web Services.
The following Graphit file gets an input LUI that extracts customer data from the CUSTOMER LU, using GET and SQL commands.
The following Graphit file gets an input LUI that extracts customer data from the CUSTOMER LU, calculates its balance and sets its status accordingly.
The output data is returned with additional information indicating whether the customer is considered:
This example illustrates how to retrieve data from multiple tables in the BILLING_DB database and use Graphit to prepare a CSV-formatted response:
Run the Graphit file in debug mode using the consecutive values 2 and 3 for the SUBSCRIBER_ID:
Notes:
The csvRow has been set to the SUBSCRIBER_ID node. Therefore, a new line has been created for each new subscriber_id entry.
The csvHeader has been set to false in the SUBSCRIBER_INFO node. Therefore, the header has been removed from the CSV output.
This example illustrates a raw-format XML output. Observe the header value displayed in the response.
Output:
<?xml version="1.0" encoding="UTF-8" standalone="no" ?><SUBSCRIBERS><CRM_DB><SUBSCRIBER_ID>97</SUBSCRIBER_ID></CRM_DB><CRM_DB><SUBSCRIBER_ID>98</SUBSCRIBER_ID></CRM_DB><CRM_DB><SUBSCRIBER_ID>99</SUBSCRIBER_ID></CRM_DB><CRM_DB><SUBSCRIBER_ID>100</SUBSCRIBER_ID></CRM_DB><CRM_DB><SUBSCRIBER_ID>101</SUBSCRIBER_ID></CRM_DB><CRM_DB><SUBSCRIBER_ID>102</SUBSCRIBER_ID></CRM_DB><CRM_DB><SUBSCRIBER_ID>103</SUBSCRIBER_ID></CRM_DB><CRM_DB><SUBSCRIBER_ID>104</SUBSCRIBER_ID></CRM_DB><CRM_DB><SUBSCRIBER_ID>105</SUBSCRIBER_ID></CRM_DB><CRM_DB><SUBSCRIBER_ID>106</SUBSCRIBER_ID></CRM_DB></SUBSCRIBERS>
When removing 'raw' as the node type, the output would be as follows:
<Root><SUBSCRIBERS><CRM_DB><SUBSCRIBER_ID>97</SUBSCRIBER_ID></CRM_DB><CRM_DB><SUBSCRIBER_ID>98</SUBSCRIBER_ID></CRM_DB><CRM_DB><SUBSCRIBER_ID>99</SUBSCRIBER_ID></CRM_DB><CRM_DB><SUBSCRIBER_ID>100</SUBSCRIBER_ID></CRM_DB><CRM_DB><SUBSCRIBER_ID>101</SUBSCRIBER_ID></CRM_DB><CRM_DB><SUBSCRIBER_ID>102</SUBSCRIBER_ID></CRM_DB><CRM_DB><SUBSCRIBER_ID>103</SUBSCRIBER_ID></CRM_DB><CRM_DB><SUBSCRIBER_ID>104</SUBSCRIBER_ID></CRM_DB><CRM_DB><SUBSCRIBER_ID>105</SUBSCRIBER_ID></CRM_DB><CRM_DB><SUBSCRIBER_ID>106</SUBSCRIBER_ID></CRM_DB></SUBSCRIBERS></Root>
This example illustrates a simple JavaScript routine that returns the higher number of the two random numbers, x and y.
Output:
This example illustrates how two values, retrieved from a previously-defined SQL query, are concatenated.
Output:
The condition defined in this file triggers either the TRUE node or the FALSE node, depending on the randomly generated values of x and y.
Output:
The x string has been added to both TRUE and FALSE groups, while the y value is not declared in the groups. The display ${x} also lists the group of origin.
Output:
This example illustrates how both the SUBSCRIBER and BILLING datasets are collected into one array.
Output:
The sessionProvider flag is set to CRM_DB in order to enable direct references to CRM_DB tables and fields.
Output:
The response returns empty due to the enabled flag affecting the entire CRM_DB node and its child nodes.
Additionally, the nice flag is set to true on the root node level. As a result, each tag of the response is indented according to the position of the tag in the document's hierarchy.
Output:
The one flag is set to true and applied to the Billing_DB2 node. As a result, the response returns only the first value for {"BILLING_DB2":{"SUBSCRIBER_ID":2}}, instead of the 10 expected values for this tag if the one flag had not been activated.
Output:
The entry flag has been set to the SUBSCRIBERS node, and therefore, the XML response displays tags around each SUBSCRIBER_ID value.
Output:
The attribute flag has been activated on all children nodes of the CRM_DB node.
Output:
The format flag in the CRM_DB node is set to XML. When a format is specified, the node is only evaluated and added if the output format matches the format value.
The example below requests JSON in the output format. The CRM_DB node, with all its subnodes, is not displayed in the response as its format is in XML.
As seen in the following example, the showEmpty flag is set to false and applied to the CRM_DB node. Empty nodes are not shown in the response.
Output:
The showNull flag has been set to false and applied to the CRM_DB node. The response does not show the LAST_NAM field in the CRM_DB node because its Null values are ignored and therefore omitted from the CRM_DB section of the response. The flag is not applied to the BILLING_DB node, and therefore Null values are shown.
Output:
The numberFormat flag has been set to 000.00 and is applied to the NumberFormat node. All responses display numberFormat with three digits before the floating point and two digits after it.
Output:
The response has been reorganized using SUBSCRIBER_ID as the key.
Output:
In this example, grInclude.graphit includes another graphit named included.graphit.
grInclude.graphit:
included.graphit:
Note that in this example, both expect to get external parameters to be used in their output.
Accordingly, if we call to the parent graphit file similar to this /api/grInclude?param1=hello¶m2=wrold
yields this output:
{"a":"hello","b":"wrold"}
This article contains several Graphit file examples. Graphit file names, when mentioned, refer to the files found in the KB Demo Project under Project Tree > Web Services.
The following Graphit file gets an input LUI that extracts customer data from the CUSTOMER LU, using GET and SQL commands.
The following Graphit file gets an input LUI that extracts customer data from the CUSTOMER LU, calculates its balance and sets its status accordingly.
The output data is returned with additional information indicating whether the customer is considered:
This example illustrates how to retrieve data from multiple tables in the BILLING_DB database and use Graphit to prepare a CSV-formatted response:
Run the Graphit file in debug mode using the consecutive values 2 and 3 for the SUBSCRIBER_ID:
Notes:
The csvRow has been set to the SUBSCRIBER_ID node. Therefore, a new line has been created for each new subscriber_id entry.
The csvHeader has been set to false in the SUBSCRIBER_INFO node. Therefore, the header has been removed from the CSV output.
This example illustrates a raw-format XML output. Observe the header value displayed in the response.
Output:
<?xml version="1.0" encoding="UTF-8" standalone="no" ?><SUBSCRIBERS><CRM_DB><SUBSCRIBER_ID>97</SUBSCRIBER_ID></CRM_DB><CRM_DB><SUBSCRIBER_ID>98</SUBSCRIBER_ID></CRM_DB><CRM_DB><SUBSCRIBER_ID>99</SUBSCRIBER_ID></CRM_DB><CRM_DB><SUBSCRIBER_ID>100</SUBSCRIBER_ID></CRM_DB><CRM_DB><SUBSCRIBER_ID>101</SUBSCRIBER_ID></CRM_DB><CRM_DB><SUBSCRIBER_ID>102</SUBSCRIBER_ID></CRM_DB><CRM_DB><SUBSCRIBER_ID>103</SUBSCRIBER_ID></CRM_DB><CRM_DB><SUBSCRIBER_ID>104</SUBSCRIBER_ID></CRM_DB><CRM_DB><SUBSCRIBER_ID>105</SUBSCRIBER_ID></CRM_DB><CRM_DB><SUBSCRIBER_ID>106</SUBSCRIBER_ID></CRM_DB></SUBSCRIBERS>
When removing 'raw' as the node type, the output would be as follows:
<Root><SUBSCRIBERS><CRM_DB><SUBSCRIBER_ID>97</SUBSCRIBER_ID></CRM_DB><CRM_DB><SUBSCRIBER_ID>98</SUBSCRIBER_ID></CRM_DB><CRM_DB><SUBSCRIBER_ID>99</SUBSCRIBER_ID></CRM_DB><CRM_DB><SUBSCRIBER_ID>100</SUBSCRIBER_ID></CRM_DB><CRM_DB><SUBSCRIBER_ID>101</SUBSCRIBER_ID></CRM_DB><CRM_DB><SUBSCRIBER_ID>102</SUBSCRIBER_ID></CRM_DB><CRM_DB><SUBSCRIBER_ID>103</SUBSCRIBER_ID></CRM_DB><CRM_DB><SUBSCRIBER_ID>104</SUBSCRIBER_ID></CRM_DB><CRM_DB><SUBSCRIBER_ID>105</SUBSCRIBER_ID></CRM_DB><CRM_DB><SUBSCRIBER_ID>106</SUBSCRIBER_ID></CRM_DB></SUBSCRIBERS></Root>
This example illustrates a simple JavaScript routine that returns the higher number of the two random numbers, x and y.
Output:
This example illustrates how two values, retrieved from a previously-defined SQL query, are concatenated.
Output:
The condition defined in this file triggers either the TRUE node or the FALSE node, depending on the randomly generated values of x and y.
Output:
The x string has been added to both TRUE and FALSE groups, while the y value is not declared in the groups. The display ${x} also lists the group of origin.
Output:
This example illustrates how both the SUBSCRIBER and BILLING datasets are collected into one array.
Output:
The sessionProvider flag is set to CRM_DB in order to enable direct references to CRM_DB tables and fields.
Output:
The response returns empty due to the enabled flag affecting the entire CRM_DB node and its child nodes.
Additionally, the nice flag is set to true on the root node level. As a result, each tag of the response is indented according to the position of the tag in the document's hierarchy.
Output:
The one flag is set to true and applied to the Billing_DB2 node. As a result, the response returns only the first value for {"BILLING_DB2":{"SUBSCRIBER_ID":2}}, instead of the 10 expected values for this tag if the one flag had not been activated.
Output:
The entry flag has been set to the SUBSCRIBERS node, and therefore, the XML response displays tags around each SUBSCRIBER_ID value.
Output:
The attribute flag has been activated on all children nodes of the CRM_DB node.
Output:
The format flag in the CRM_DB node is set to XML. When a format is specified, the node is only evaluated and added if the output format matches the format value.
The example below requests JSON in the output format. The CRM_DB node, with all its subnodes, is not displayed in the response as its format is in XML.
As seen in the following example, the showEmpty flag is set to false and applied to the CRM_DB node. Empty nodes are not shown in the response.
Output:
The showNull flag has been set to false and applied to the CRM_DB node. The response does not show the LAST_NAM field in the CRM_DB node because its Null values are ignored and therefore omitted from the CRM_DB section of the response. The flag is not applied to the BILLING_DB node, and therefore Null values are shown.
Output:
The numberFormat flag has been set to 000.00 and is applied to the NumberFormat node. All responses display numberFormat with three digits before the floating point and two digits after it.
Output:
The response has been reorganized using SUBSCRIBER_ID as the key.
Output:
In this example, grInclude.graphit includes another graphit named included.graphit.
grInclude.graphit:
included.graphit:
Note that in this example, both expect to get external parameters to be used in their output.
Accordingly, if we call to the parent graphit file similar to this /api/grInclude?param1=hello¶m2=wrold
yields this output:
{"a":"hello","b":"wrold"}