Docs‎ > ‎Logic Designer‎ > ‎Live Logic‎ > ‎

Logic Libraries

When you write rules using JavaScript, you will often benefit from using pre-existing libraries.

Each project can use any number of libraries, which can be selected in the Logic Designer. You should only select those libraries that you will in fact use, since there is a cost in CPU and memory associated with each additional library.

Once you have added a library to a project, you can immediately take advantage of it and start using its facilities in your rules.

Example

Let's assume that you have a table called Orders, with two attributes: order_date and shipping_date. You would like to have a computed attribute called processing_delay showing the time elapsed between these two dates.

The easiest way to do this might be to use the excellent moment.js library:

var orderDate = currentBean.order_date.getTime();
var shippingDate = currentBean.shipping_date.getTime();
currentBean.processing_delay = moment(orderData).from(shippingData, true);

This could also be done with Java objects, of course.

Comments