Skip to content


Tech Tuesday: Useful Javascript Commands

With the launch of, another scripting language has been introduced for users to create new calculated columns and scripts. We’re going to take a quick look at a couple useful scripts and commands that will assist in building out integrations.

For these examples I’ll describe what each script should help with, then list out what the source field names would be for each example, and finally I’ll show the actual syntax that would be used to build each.

A quick note if you are copying the scripts out from this article: Double-check any of the single quotes in the scripts, word editors and blog sites like to format the single quotes to make them easier to read but it technically makes it a different character in the script compiler. I would copy these scripts out to notepad and re-type the single quotes to ensure they show up as a basic single quote without formatting.


Let’s start with a straightforward scenario. We have a first name and a last name in the source data and we need to concatenate it into 1 field for the destination. I will be assuming our column names are FirstName and LastName for this script. The syntax would be as follows:

return this._FirstName.trim() + ‘ ‘ + this._LastName.trim();

The code will take the first name and last name columns and apply a trim statement to each. The trim statement removes any extra whitespace characters before or after the actual data. The single quotes in the middle of the statement are there to ensure a space is added between the first and last name when building the new string.


Another good example is needing to come up with the current date and/or time value. A common scenario this is used for it to create a batch ID that has a datetime stamp as part of the value. In this case, I won’t be using anything from the source data, instead I want the beginning of the batch to have the value “EONE_” and then the date to follow in year-month-day format (ie: EONE_2019-02-19):

var today = new Date();

var day = today.getDate();

var month = today.getMonth();

var year = today.getFullYear();


month = month + 1;


if (day < 10) {

     day = ‘0’ + day;



if (month < 10) {

     month = ‘0’ + month;



var myBatch = ‘EONE_’ + year + ‘-‘ + month + ‘-‘ + day;


return myBatch;

There is a bit going on with this script so we’ll walk through it. The first 4 lines are declaring the variable for the current date, and then getting each individual component of it (day, month, year). After that, the month has to be increased by 1, as the Javascript getMonth() function returns a 0-11 for the month – which isn’t how humans number their months.

After that, both the month and day values are checked to see if they are less than 10. If they are, the value needs to have a 0 padded to the front of it to keep it at 2 characters so that our batch ID is formatted correctly (ie, padding a 0 to 7, to make the value 07).

Finally, all the components are concatenated together to build the value that will be returned and mapped through to the destination.


Each of those examples and the code included can be taken and adjusted as needed for real world integrations and problems that need to be solved. The Javascript used within the scripting windows in will match standard syntax that can be built in any editors. Along that point, using online Javascript editors to test out different statements and code snippets is extremely helpful. There are multiple options out there to try, but one that I personally make use of is:


If you have other scripting scenarios you’d like to cover or have questions related to the examples above, comment below and we’ll reply and help out – either through the comments below or in another Tech Tuesday. Thanks!




Leave a Comment


Join eOne Solutions for the Q3 Partner All Hands Call!
SmartList Trek: SmartList Builder, Popdock & Your Future - New Popdock Trainings, August 2022
See eOne's Winning Virtual Integration for Salesforce
2022 Q3 Promotions
New Features & Updates in SmartConnect 21 - Recording Now Available!


2016 SmartConnect Integration Bootcamps
Tech Tues: Automatically refreshing Pivot Tables in Excel Refreshable Reports
Happy Thanksgiving from the eOne team!
2017 SmartConnect Integration Bootcamps
New Releases of Extender and SmartList Builder



Business Central CRM D365 Business Central Dynamics 365 dynamics crm Dynamics GP Dynamics NAV Econnect Employee Spotlight eone eOne News error Error Message Events Excel Excel Report Builder Extender Flexicoder GP integration Map Meet the Team Microsoft dynamics crm Microsoft Dynamics GP Navigation List Builder Office Relationships Partner All Hands Call Popdock promotions release SalesForce SmartConnect SmartConnect Bootcamp SmartConnect Maps SmartConnect Office Hours SmartList SmartList Builder SmartPost SmartView SQL Tech Tuesday Templates training

Integrate & Automate without Any Code.

SmartList Data has Never Been Faster.

The Easiest Way to Report on GP Data.