Introduction

Getting started

Walkthrough Guides

CafeX Apps

Workflows

Using CafeX Collaborate App

Reporting

Managing CafeX

Integrating CafeX

Security

App Studio

App Studio Components

CafeX Apps

Using a JavaScript Data Set

Modified on Mon, 2 Dec at 9:06 AM

As an App Builder, you use JavaScript Data Sets to perform advanced operations or modify existing Data Sets within your Apps. The JavaScript Data Set provides you with a means to write code. However, for security, only libraries and functions that are safe to use are available to you. This means that certain JavaScript features may not be available for you to maintain the security and stability of your App and the platform.


To use a JavaScript Data Set, you must provide input data and configure the output schema. The output schema ensures that other App Studio Components and Data Sets can identify and work with the fields that you define.


Important: If your JavaScript Data Set does not display the data you expect, check that it returns values that match the output schema that you define. Components in the App Studio only recognize the fields you define in the output schema. If your code returns the fields that are not part of the schema, those fields will not be visible or usable by components. However, at runtime, you can still pass the output of this Data Set into another JavaScript Data Set, where the additional fields can be evaluated and used. 


Key Limitations

When working with JavaScript Data Sets, be aware of the following limitations:

  • Execution time: The code must execute and return a response within 3 seconds. If it takes longer, you encounter an error: No response was returned within 3000 ms.
  • Output size: The maximum size of the output data is 1 MB (1,048,576 bytes). If the returned data exceeds the limit, an error occurs: Response data is longer than 1,048,576 bytes: [size].


Example JavaScript Data Set


JavaScript Data Sets can perform some very advanced operations. Although below is a contrived example, it demonstrates the core aspects of using it.


Scenario:

Your App uses an API to present records in a Table. Each record that the API returns has an indicator field that contains the value true or false. Your App needs to present this data as "Approved" or "Denied" to the User.


Solution:

The JavaScript Data Set displayed below can perform this operation.


Code Breakdown:

Line 1: The variable inputs is reserved. You use this to reference the input data sets.


Line 4: References the approved field in the original data set and checks its value.


Line 5 and 7: Updates the value of the field on the input object based on the evaluation result.


Line 11: The return matches the Output schema.


The following uses two Table Components to show the original input Data Set, and the effect that the JavaScript Data Set has.



Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article