- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-26-2017 05:31 AM
Hi,
We're on Helsinki...
I just finished watching a video from ChuckT. from 2014 regarding the use of a 'global' variable within a Script Include. In my case I would like something very similar to assist in a Transform Map.
To borrow from the video -- is it possible to have, say --->
OnBefore:
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
//my Global variable??
if (MyVAR == 'undefined')
MyVAR = 'some_original_thing';
if (source.some_source_field != '')
MyVAR = source.some_source_field;
else
source.some_source_field = MyVar;
//I am trying to 'recall' a value from a 'previous' row for subsequent rows that do not have that some_source_field set
})(source, map, log, target);
in the video it was stated that a variable not declared with 'var' will be 'global' --- does this work for Transform Maps?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-26-2017 05:35 AM
Hi Anthony,
Yes, you can do this with a transform script. Declare it in an onStart script and it's available to other scripts within the transform process.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-26-2017 06:34 AM
You bet! Come find me. I'm in 2 days of pre-con training. Tuesday-Thursday I'll be in the CreatorCon Dev Hub most of the time. I've got live sessions on the developer theater from 12:40 to 1:20 Tue/Wed. I look forward to seeing you there!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-09-2018 08:11 AM
This appears to be untrue in Jakarta. I have an onStart script which contains...
var count = 0;
My field map script contains
count++;
I get the following log message: org.mozilla.javascript.EcmaError: "count" is not defined.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-11-2020 01:21 PM
did you find any solution?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-21-2021 01:30 AM
Transform Map onStart event scripts can no longer declare global variables
We have to create global variables outside the function
"The recommended practice is to not use global variables inside transform map event scripts. If global variables are needed, they can be declared outside function template and passed in, and the previous template will have to be removed"
-Anders