Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

re-usable, global custom JS functions across different rules

Avatar

Avatar
Ignite 1
Level 1
Vanontherun-osC
Level 1

Like

1 like

Total Posts

1 post

Correct Reply

0 solutions
Top badges earned
Ignite 1
Boost 1
View profile

Avatar
Ignite 1
Level 1
Vanontherun-osC
Level 1

Like

1 like

Total Posts

1 post

Correct Reply

0 solutions
Top badges earned
Ignite 1
Boost 1
View profile
Vanontherun-osC
Level 1

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

Avatar

Avatar
Coach
MVP
ursboller
MVP

Likes

517 likes

Total Posts

1,016 posts

Correct Reply

255 solutions
Top badges earned
Coach
Contributor
Bedrock
Seeker
Springboard
View profile

Avatar
Coach
MVP
ursboller
MVP

Likes

517 likes

Total Posts

1,016 posts

Correct Reply

255 solutions
Top badges earned
Coach
Contributor
Bedrock
Seeker
Springboard
View profile
ursboller
MVP

24-10-2018

Private Extensions in Launch should solve your problem:

Private Extensions are Coming!

Avatar

Avatar
Springboard
MVP
StewSchilling
MVP

Likes

334 likes

Total Posts

272 posts

Correct Reply

84 solutions
Top badges earned
Springboard
Bedrock
Validate 1
Establish
Contributor
View profile

Avatar
Springboard
MVP
StewSchilling
MVP

Likes

334 likes

Total Posts

272 posts

Correct Reply

84 solutions
Top badges earned
Springboard
Bedrock
Validate 1
Establish
Contributor
View profile
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:

return function(a, b) {

  return a + b;

}

 

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

var addTwoNumbers = _satellite.getVar("func_addTwoNumbers");

var result = addTwoNumbers(10, 30);

// result will be === 40