Transform data
Modify or combine values
Filter data
Remove data from the integration
Business rule structure
Every business rule is a JavaScript arrow function that receives a parameter and returns a value.context contains the current data being processed, and the function returns a value that can be used in the integration.
Object reference
| Properties | Contains | Access |
|---|---|---|
| object | Current unit of data being processed | context.object |
| resources | Enrichment response | context.resources.{{enrichmentName}}.{{completeFieldPath}} |
| params | Parameters used in Extraction | context.params |
Reusable rule
In RWS Integration it is possible to reuse an existing rule.When to use
- When the same logic is used in multiple rules
- To encapsulate very complex logic
How it works
You can use theBusinessRule.transform function to call an existing rule, it works with the following parameters:
| Parameter | Description |
|---|---|
| tenantId | The ID of the tenant where the rule should be executed |
| ruleId | The ID of the business rule to be called |
| object | The object data that the other rule should use |
Example
To create a reusable rule for price formatting and call it from other rules: Price Formatting Rule (ID:67f51e19c8a10ceefa121cd2):
Auxiliary libraries
RWS provides several JavaScript libraries that you can use in your business rules| Library | How to use | Documentation |
|---|---|---|
| Lodash | Global variable _ (underscore) | Lodash documentation |
| Dayjs | Global variable dayjs | Day.js documentation |
| Decimaljs | Global variable Decimal | Decimal.js documentation |