Introduction

Getting started

Walkthrough Guides

CafeX Apps

Workflows

Using CafeX Collaborate App

Reporting

Managing CafeX

Integrating CafeX

Security

CafeX Apps

Using a JavaScript Data Set

Modified on Tue, 19 Sep 2023 at 08:49 AM

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


As with all Data Sets, you have to provide the input.  The JavaScript Data Set also requires you to configure the output schema, so that other App Studio Components and Data Sets can make sure of the fields that you define.


Important: If you find that your JavaScript Data Set does not display the data you expect, check that the Data Set returns a value that matches the schema that you define.  Only the fields on the output schema are available in the rest of the App Studio. If you return the incorrect values or a different data structure, they are not available to you.


Example JavaScript Data Set


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


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 "Approved" or "Denied" to the User.


The following JavaScript Data Set can perform this operation:


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.


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 atleast one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article