Apex Designer Documentation
What's New
Getting Started
Projects
Business Objects
Processes
User Interfaces
App Behaviors
Files
Dependencies
Project Settings
Libraries
Patterns and Best Practices
App Showcase
Frequently Asked Questions

Using An Npm Module In A Business Object Behavior

Extending your functionality using an outside package

Blank Profile Image
Written by Keith Miller
Updated 3 years ago
Less than a minute read

When we need to extend the functionality of a business object behavior, there are two options.  You could write the code yourself or you can use an external package. With Apex Designer being a Node.js application, the use of an NPM package makes logical sense and we have made it easy to do.

Adding the Dependency to the Behavior

Date Manipulation is a common need for an application. One of our favorite NPM packages to do that is day.js

First, be sure that you have added the package to the project on the server side as described in Dependencies. Then in the behavior simply start typing its name in the Add dependency field and click the name to add it.

Behavior page dependencies

If you expand the dependency panel, you can see the alias used to reference it.

dayjs dependency

The to use it in your method, just reference it by alias 

//monthDate is an input parameter of type date
var  daysInMonth = dayjs(monthDate).daysInMonth()
return daysInMonth

 

Powered by Apex Designer
Terms of ServicePrivacy Policy
© 2017-2024 Apex Process Consultants