Data mapper made in old version of Connect designer, opened in new version?

Hi,

I got a data mapper created from version 2022.2.1.13107

Now our server got the new 2023.1.0 designer installed. So I thought to opened it using the new designer. And I notice this a particular field thats now returning this as the value:

image
The code in the field is as follow:
image
This works in version 2022.2.1 as below, string being padded by zero:

image

So my assumption is we might have to update our templates/datamapper once we fully upgraded as might not be all backward compatible?
As for fixing the script, is this the right away to assign value to the field too?

It looks like calling a function is now not allowed and not being executed by the looks of the value.

Any advice would be appreciated.

Thank you

Regards,
Ernani

This works:

(function (content, len, padding) {
  var val = content.toString();
  if (val.length > len) {
    val = val.substring(0, len);
  } else {
    var rep = len - val.length;
    for (var n = 0; n < rep; n++) {
      val = padding + val;
    }
  }

  return val;
})(record.fields.SortOrder,6,"0");

But still I would have to come in and change all my data mapper, that have the old script to this format instead.

That is strange… It must have been caused by an optimization of the JavaScript engine, which now apparently requires all functions to be declared prior to being called. So your original code needs to be switched around:

function alignRight(content, len, padding) {
  var val = content.toString();
  if (val.length > len) {
    val = val.substring(0, len);
  } else {
    var rep = len - val.length;
    for (var n = 0; n < rep; n++) {
      val = padding + val;
    }
  }

  return val;
}
alignRight(record.fields.SortOrder,6,"0");

Apparently, none of our QA test cases tested for the return value of a function. I will notify QA. But unfortunately, in the meantime, you’ll have to make changes to the extraction step in your DataMapper configuration.

By the way, there is a native method in JavaScript named padStart() that does exactly the same thing, so you can get rid of your user-designed function:

record.fields.SortOrder.padStart(6,"0");

Hi Phil,

Ah right. That is strange indeed, to have to switch it around as JS works with the former format.

And thanks for the native padStart() I do know that theres discrepancy between the JS engine used in designer(newer) and Workflow(vanilla).

So I think when I did it , I wanted scripts consistent with whatever platform im using (designer/workflow). Im not sure if this has been addressed or not or will be addressed in the future releases.

For now looks like I have to come in to change this in all the datamapper/template currently in workflow that has the unsupported format on new version of connect… :frowning: where function declaration needs to be at the beginning of the script.

Thank you Phil.

padStart() is also available in Workflow when you set the scripting language to Enhanced JScript.

1 Like