Highlighted

re-usable, global custom JS functions across different rules

Vanontherun-osC

18-10-2018

Is there a way to have have re-usable javascript functions that can be used across various rules (within other custom functions)? Perhaps a new feature in Launch?

It would be pulled in like an include or some other mechanism and be in the same scope as the calling custom function in a rule.

Thanks,
Van

Replies

Highlighted

StewSchilling

MVP

07-11-2018

Data Elements are your friend.  People often forget that the can return ANY javaScript object (not just strings).

I often use DTM data elements to provide functions or function libraries.

For example, in a DTM (custom code) data element named "func_addTwoNumbers", I might have this:

Then in a number of places where I want to use this function, I would do this:

Alternately you could do this: