eval.js functions getsrc and getint

Created: 2020-10-30 10:55:15
Modified: 2023-07-06 12:35:44
Tags: Custom Mapping Features Javascript UnitySync

As of v4.0, two default functions have been added inside javascript (clarification, they do NOT need to be added to eval.js). Call these functions within custom eval.js functions to get desired source attributes and/or internal variables without having to pass them to the function.

getsrc(‘attrib’) this will use the original source value ‘attrib’ (If multi-valued, only the first value is used).

getint(‘attrib’) this will use the internal variable value for ‘attrib’ (if there is one). (Always single valued).

Note: getsrc and getint will return a “javascript undef” warning if the specified attrib could not be found.

Both functions grab the attrib value directly from the source data. This allows the creation of custom eval.js javascript functions that do not need to receive the attributes from the custom mapping that calls a eval.js routine.

In the below example, neither ~sn~ nor ^sn^ need to be passed when the custom mapping calls the function.

Note: These functions allows for the scenario where a source value contains a single quote (‘) or double quote (“).

Example custom eval.js function:

function return_two_values_not_passed(mystring)
{

var srcsn = getsrc('sn');
var intsn = getint('sn');

return mystring + ': ' srcsn + ' and ' + intsn;
}

Example Custom Mapping:

Description=&return_two_values_not_passed(‘^Description^’)&

Example source values:

^SN^ is: Mac Arthur
~sn~ is: Mac
^Description^ is: Two Last Name Values

The return value for the above:

Two Last Name Values: Mac Arthur and Mac

Side note: The function may also be called without parameters:
i.e.
Description=&return_two_values_not_passed()&

Share this article:
Knowledgebase

Directory
  1. Directify - Self Service

  2. Mimic - Replication

  3. UnitySync - Sync
Password
  1. emPass - Sync
Obsolete
  1. Profiler
  2. SimpleSync