DirWiz Logo

Article Tags

eval.js functions getsrc and getint

2021-06-03 16:01:28
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 this function 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 pull the first value of the source attrib

getint(‘attrib’) this will pull the internal variable (always single valued)

Both will return a javascript undef if the attrib could not be found.

The two new functions grab the value directly from the source data (if multi-valued, pulls the first). This allows the creation of custom eval.js javascript functions without the need to pass variables when called from a custom map file.

In the below example, neither ~sn~ nor ^sn^ need to be passed to the function ‘mystring’.

Input parameter ‘mystring’ will still be the value(s) you pass directly into your custom eval.js function. i.e. ^employeeid^.

Custom Mapping: Description=&return_two_values_not_passed(‘^employeeID^’)&

function return_two_values_not_passed(mystring)

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

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

When (quotes not part of value):

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

The return value is for the above:

“Two Last Name Values: Mac Arthur and Mac”

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

Share this article: Twitter reddit